嗨大家我的任务是将自定义框架从joomla 1.5移动到3.0我已经得到了完美加载主页的框架但是当我去其他页面时css不会加载这里是代码:
PHP:
<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->templateurl(); ?>/css/addons.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/layout.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/template.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/typo.css" type="text/css" />
HTML输出:
<link rel="stylesheet" href="http://flyvail/index.php/templates/system/css/system.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/system/css/general.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/addons.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/layout.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/template.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/typo.css" type="text/css" />
<!-- CSS for handheld devices -->
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/handheld/layout.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/handheld/template.css" type="text/css" />
<!-- CSS for handheld devices -->
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/handheld/layout.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/handheld/template.css" type="text/css" />
<!-- //CSS for handheld devices -->
我不确定为什么它没有正确加载
答案 0 :(得分:0)
假设这是在你的模板的index.php文件中,那么试试:
$doc = JFactory::getDocument();
$doc->addStyleSheet($this->baseurl.'/templates/'.$this->template . '/css/NAMEOFSTYLESHEET.css', $type = 'text/css', $media = 'screen,projection');
添加样式表。
我的猜测是$this->baseurl()
不能与()
一起使用,因为它是一个参数,而不是一个函数。因此,显示的链接没有baseurl由相对链接生成,该链接也考虑了joomla设置的基本href。这意味着当您不在站点的根目录中时,链接是错误的。
(如果您刚刚删除了所有的(),您的代码可能会有效,但是更好的做法是使用addStyleSheet方法)
如果这不起作用,您是否可以查看在您说它有效的主页上生成的网址是否不同以及您说它不支持的子网页,并添加此附加信息你的问题。