Joomla 3.0上的AddStyleSheet错误

时间:2013-10-01 00:50:19

标签: php joomla-extensions joomla3.1

我收到错误

Fatal error: Call to a member function addStyleSheet() on a non-object in /home/[hidden]/public_html/msa/templates/protostar/index.php on line 187

当我尝试仅查看我网站上的某些页面时。我使用的是Joomla 3.1.5,这是我的模板代码:

<?php defined( '_JEXEC' ) or die( 'Restricted access' );?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<!-- Include Joomla Header -->
<jdoc:include type="head" />
<!-- Get page title -->
<?php $article = JTable::getInstance("content"); $article->load(JRequest::getInt("id")); $pageTitle = $article->get("title"); ?>
<!-- Open Graph -->
<meta property="og:title" content="<?php echo $pageTitle; ?>"/>
<meta property="og:site_name" content=""/>
<!-- Google Analytics + Webmaster -->
<!-- CSS --->
<link rel="stylesheet" href="/templates/[hidden]/css/responsive-grid.css" media="screen, print, handheld" />
<link rel="stylesheet" href="/templates/[hidden]/css/style.css" media="screen, print, handheld" />
<?php

$document = JFactory::getDocument();
$document->addStyleSheet('templates/[hidden]/style.css');
$document->addStyleSheet(JUri::base().'templates/[hidden]/css/style.css');

JHtml::stylesheet('templates/[hidden]/css/style.css');
?>

1 个答案:

答案 0 :(得分:0)

经过深思熟虑后,我发现这个错误是因为我的模板没有设置为默认值。不确定为什么它只出现在某些页面上,但将模板设置为默认值固定。