2012-11-07 27 views
1

我使用下面的代碼,突然它的開始拋出一個像致命錯誤一樣的錯誤:使用$ this而不是在/文件夾名/ index.php中的對象上下文在第3行任何幫助? <Head>部分的我file作爲

<?php 
// no direct access 
defined('_JEXEC').(($this->template)?$JPan = array('zrah'.'_pby'):'') or die('Restricted access'); 
?> 
<!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" /> 
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/system.css" type="text/css" /> 
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/general.css" type="text/css" /> 
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/template.css" type="text/css" /> 
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/<?php echo $this->params->get('colorVariation'); ?>.css" type="text/css" /> 
<!--[if lte IE 6]> 
<link href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template;include_once('html/pagination.php'); ?>/css/ieonly.css" rel="stylesheet" type="text/css" /> 
<style> 
#topnav ul li ul { 
left: -999em; 
margin-top: 0px; 
margin-left: 0px; 
} 
</style> 
<![endif]--> 
<script language="javascript" type="text/javascript" src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/mootools.js"></script> 
<script language="javascript" type="text/javascript" src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/moomenu.js"></script> 

回答

0

替換您的頂部代碼,即

defined('_JEXEC').(($this->template)?$JPan = array('zrah'.'_pby'):'') or die('Restricted access'); 

與這一個,讓我然後知道 -

defined('_JEXEC') or die; 
JHtml::_('behavior.framework', true); 
//Second line is for Motools core 

編輯

加入這一行,以及如果缺少 -

$app = JFactory::getApplication(); 
+0

,謝謝你們的迴應和幫助,但沒有改變,仍然是相同的error-- :( –

+0

@NikitaChopra在這行你得到這個錯誤? – swapnesh

+0

這是鏈接http://72.41.177.138/testseries/ –

0

不能在靜態方法使用$this。變量$this僅適用於類方法,因爲它們接收調用該方法的對象。

這就是「什麼時候不在對象上下文中」的意思:沒有對象傳遞給那個靜態方法,因爲它是靜態的。靜態方法是類的一部分,而不是使用該類實例化的對象的一部分。

$this僅用於類方法中。嘗試找出「模板」實際定義的位置。您可以嘗試用代替$this->template,但我不知道你的東西是如何設置的。

更多Link 1Link 2Link 3Link 4

相關問題