2014-11-22 73 views
1

我想添加一个名为ie.css的只有css文件的Internet Explorer。Internet Explorer css:Joomla自定义模板

我已经建立了一个简单的自定义joomla模板,它在每个浏览器中工作正常,除了....通常的罪魁祸首IE浏览器!

我已经将ie.css添加到了css文件夹,并且我正努力使文件只能从IE中读取。 这是我的PHP文件:

<?php 
 

 
$doc = JFactory::getDocument(); 
 

 
$doc->addStyleSheet('templates/' . $this->template . '/css/main.css'); 
 
    $doc->addStyleSheet('templates/' . $this->template . '/css/header.css'); 
 
    $doc->addStyleSheet('templates/' . $this->template . '/css/footer.css'); 
 
    $doc->addStyleSheet('templates/' . $this->template . '/css/container.css'); 
 
$stylelink = '<!--[if lte IE 9]>' ."\n"; 
 
$stylelink .= '<link rel="stylesheet" href="/css/ie.css" />' ."\n"; 
 
$stylelink .= '<![endif]-->' ."\n"; 
 
    
 
$document = JFactory::getDocument(); 
 
$document->addCustomTag($stylelink); 
 
$doc->addScript('/templates/' . $this->template . '/java/java.js', 'text/javascript'); 
 

 

 
?> 
 
<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 

 
<jdoc:include type="head" /> 
 

 
<!--[if gte IE 9]> 
 
    <style type="text/css"> 
 
    .gradient { 
 
     filter: none; 
 
    } 
 
    </style> 
 
<![endif]--> 
 
<!--[if IE]> 
 
\t <link rel="stylesheet" type="text/css" href="css/ie.css" /> 
 
<![endif]--> 
 

 
</head> 
 

 
<body> 
 
<div id="back"> 
 

 
<jdoc:include type="modules" name="background_image" style="none" /></div> 
 
<div class="wrapper"> 
 
     <div id="logo"><jdoc:include type="modules" name="logo" style="none" /></div> 
 
     
 
    <div class="menu"> 
 
    <jdoc:include type="modules" name="nav-main" style="none" /> 
 
     
 
     
 
    </div> 
 
    
 
    <div class="container"> 
 
    <jdoc:include type="component" /> 
 
     <div id="home_content_top"> 
 
     <jdoc:include type="modules" name="content_area_one" style="none" /> 
 
     </div> 
 
     
 
     <div id="home_discount"> 
 
     <jdoc:include type="modules" name="content_area_two" style="none" /> 
 
     </div> 
 
     
 
     <div id="footer"> 
 
      <jdoc:include type="modules" name="footer" style="none" /> 
 
     
 
     
 
     </div> 
 
    </div> 
 
     
 

 

 

 
</div> 
 
</body> 
 
</html>

我在哪里出了错?

回答

0

您尚未定义时,试图打电话给你的CSS文件,所以目前它试图找到基本路径:

www.example.com/css/ie.css 

当实际路径是:

www.example.com/templates/YOUR_TEMPLATE/css/ie.css 

另外,我想不使用PHP来渲染条件语句。这是干净得多做到这一点没有,所以删除了这一切:

$stylelink = '<!--[if lte IE 9]>' ."\n"; 
$stylelink .= '<link rel="stylesheet" href="/css/ie.css" />' ."\n"; 
$stylelink .= '<![endif]-->' ."\n"; 
$document = JFactory::getDocument(); 
$document->addCustomTag($stylelink); 

添加添加以下的<head>标签中:

<!--[if lte IE 9]> 
    <link rel="stylesheet" href="templates/<?php echo $this->template; ?>/css/ie.css" /> 
<![endif]--> 

只是一个方面说明了。您不需要拨打JFactory::getDocument()两次,只需要一次,就像您在代码的顶部一样。

+0

非常感谢你! – ADRIAN 2014-11-23 07:32:19