2014-09-01 31 views
0

我使用CodeIgniter Template和CodeIgniter PHP框架。我不知道這個庫中的元數據是如何工作的(模板)。我嘗試添加style.css到我的佈局。在用戶手冊,我發現信息:CodeIgniter中的Style.css PHP和模板庫

**prepend_metadata()** 

Add a line to the start of the $template['metadata'] string. 

    Parameters 

    $line - string REQUIRED - Metadata line. 
    Usage 

      $this->template->prepend_metadata('<script src="/js/jquery.js"></script>'); 

在我的佈局文件,我有:

<head> 
<title>TITLE</title> 
<?=$template['metadata']?> 
</head> 

在Controller文件:

$this->template 
        ->prepend_metadata('<link rel="stylesheet" href="css/style.css" type="text/css" media="all" />') 
        ->set_layout('index'); 

這看起來不錯,但不一切工作。

Style.css位於views/css/style.css中,佈局文件(index.php)位於views/css/layout/index.php中。

感謝您的幫助!

+0

嘗試使用HREF = '<= BASE_URL()?> CSS/style.css中' – Sudarshan 2014-09-01 14:42:57

+0

'BASE_URL()'+''/目錄/路徑/到/ css''或'BASE_URL ('directory/path/to/css')' – tomexsans 2014-09-01 17:48:43

+0

I tired base_url(「appli陽離子/ views/css/style.css「)或者base_url()?> css/style.css和nothing; / – 2014-09-01 21:03:35

回答

0

我找到了我的問題的解決方案。

第一步:在.htcaccess文件我加了 'CSS' 來RewtireCond

RewriteCond $1 !^(index\.php|images|robots\.txt|css) 

第二步:我創建了 '資產' 文件夾旁邊的 '系統'/ '應用程序' 文件夾

第三步:我有使用該稱道

->prepend_metadata('<link rel="stylesheet" href="'.base_url("assets/css/style.css").'" type="text/css" media="all" />')