joomla 1.5自定义移动框架不加载css


joomla 1.5 Custom mobile framework not loading css

嗨,我的任务是将自定义框架从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 -->

我不知道为什么它不加载正确

假设这是在模板的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设置的base href。这意味着当你不在网站的根目录时,如果链接是错误的。

(如果您只是删除了所有的(),您的代码可能会工作,但addStyleSheet方法是更好的实践)

如果这不起作用,你可以看看你的主页上生成的URL是否不同,你说它起作用,子页面上你说它不起作用,并将这些额外的信息添加到你的问题