2

i don't really know php and have hit a brick wall.

The problem is that my site is showing the following error...

Fatal error: Using $this when not in object context in /hermes/web07/b2350/pow.thefoodie/htdocs/index.php on line 11

This is the begining of my index.php file...

<?php 
/*
  Joomla templates by Joomladesigns.co.uk
 */

// no direct access
 define( 'YOURBASEPATH', dirname(__FILE__) );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >
<head>
<jdoc:include type="head" />
<!--[if lte IE 6]>
<style type="text/css">
#main_body ul li { behavior: url(<?php echo $this->baseurl; ?>/templates/<?php echo $this->template ?>/css/iepngfix.htc) }
</style>
<script defer type="text/javascript" src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template ?>/js/pngfix.js"></script>
<![endif]-->
<link href="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template ?>/css/template_css.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template ?>/js/fx_styles.js"></script>
<script type="text/javascript" src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template ?>/js/accordion.js"></script>

<?php

 // *************************************************
 //
 // Template Parameters
 //
 // *************************************************

 $h1         = $this->params->get("logo");
 $linked_h1    = ($this->params->get("logoLinked", 1)  == 0)?"false":"true";
 $h1_title    = $this->params->get("logoTitle"); 
 $h2_motto  = $this->params->get("logoMotto");

 // Please do NOT change this unless you know what you doing.

 $template_path = $this->baseurl.'/templates/'.$this->template; // template path

 $default_font = "default";


 // **************************************************

?>

</head>

Any help would be great as i am completely lost.

2
  • 1
    haha.. sorry, bb code doesn't work ;) good try though! Commented Apr 8, 2010 at 6:14
  • I'm not really sure what i'm doing, i have no php knowledge really and don't understand it, i will try what you guys suggested. Also what is the code to put around code when posting? Thnaks guys and i will let you know how i go Commented Apr 8, 2010 at 7:21

2 Answers 2

1

The error is pretty self-explanatory. Looks like it's choking on this bit:

<?php echo $this->language; ?>

$this is only meant to be used inside class methods. Try to find out where "language" is actually defined. You can try replacing $this->language with just $language but I don't know how your stuff is set up.

Edit: Actually, it doesn't look like you have any include statements at all prior to that... so nothing should be defined. Unless something else is including your index.php file, but that's a bit unusual for the index to be included.

If you copied that Joomla template from somewhere, you probably put it in the wrong place.

Sign up to request clarification or add additional context in comments.

Comments

1

Well you can only use $this inside of a class. Outside of a class, $this shouldn't exist. It basically references the current class object that you're working inside of. To get this working properly, you need to define a variable as a new class and then reference everything through that variable, such as:

$myvar = new MyClass();
$h1 = $myvar->params->get("logo");

If that's the kind of thing you're doing.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.