2014-09-04 34 views
0

我添加了一個名爲「css_url」的新函數。我在控制器的構造函數中設置,它工作。 此外,我想要在資產範圍內。在視圖目錄中放置主題,每個主題都有自己的資源。我如何能夠在視圖目錄中訪問資源?視圖中的Codeigniter css

-view 
--theme1 
---assets 
----css 
----js 
----images 
-----f1.jpg 

在這裏輸入的代碼

public function __construct() { 
    parent::__construct(); 
    // Temel veriler veri tabanından çekilecek; 
    $this -> theme = "theme1"; 

    $this->config->set_item('css_url', $this->theme); 
} 

css_url( 「圖像/ f1.jpg」);

+0

最佳實踐,將您的資產,主題文件夾位於codeigniter根目錄下,這是應用程序和系統文件夾的位置。因此,您可以使用'base_url()'方便地訪問它。 讓我知道如果您需要進一步幫助 – Zeeshan 2014-09-04 14:57:39

回答

0

轉到的application/config/autoload.php和URL助手這樣的...

$autoload['helper'] = array('url'); 

現在你可以使用這樣的base_url()函數來訪問你的看法資產文件夾...

<?php echo base_url('assets/css/yourstyle.css'); ?> 

將你的資產在你的應用程序的根文件夾...

application/ 
assets/ 
system/