2014-11-22 54 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