{} PHP Fatal error: $ bu değil nesne bağlamında (Joomla) kullanma

2 Cevap php

ben gerçekten php bilmiyorum ve bir tuğla duvara vurdu.

Sorun benim sitesi aşağıdaki hata gösteriyor ki ...

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

Bu benim index.php dosyasının başlangıçtır ...

<?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>

I tamamen kaybolmuş olduğum gibi herhangi bir yardım büyük olurdu.

2 Cevap

Hata oldukça kendini açıklayıcı. Bu bit boğulma gibi görünüyor:

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

$this sadece sınıf yöntemleri içinde kullanılmak içindir. "Dil" aslında tanımlanır nerede bulmaya çalışın. Sadece $language ile $this->language yerine deneyebilirsiniz ama ben şeyler kurmak bilmiyorum.

Bunu önce hiç bir include ifadeleri var gibi Edit: Aslında, o görünmüyor ... yani nothing tanımlanmalıdır. Başka bir şey index.php dosya dahil edilir, ancak endeks dahil edilmesi için bu biraz sıradışı sürece.

Eğer bir yerde o Joomla şablonu kopyalanamaz, muhtemelen yanlış bir yere koyun.

Peki sadece $this, bir sınıfın içinde kullanabilirsiniz. Bir sınıfın dışında, $this var olmamalıdır. Bu temelde içinde çalışıyoruz geçerli sınıf nesneye başvurur. Bu düzgün çalışan almak için, yeni bir sınıf olarak bir değişken tanımlamak gerekiyor ve sonra gibi bu değişken aracılığıyla her şeyi referans:

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

Bu yaptığınızı şey tür eğer.