我添加了名为“css_url”的新函数。我在控制器的构造函数中设置,它有效。 此外,我想在资产方面达成共识。在视图目录中我放置了主题,每个主题都有自己的资产。如何访问视图目录中的资产?
-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”);
转到 application/config/autoload.php 和 url 帮助器,如下所示...
$autoload['helper'] = array('url');
现在您可以使用这样的 base_url() 函数访问视图中的资产文件夹...
<?php echo base_url('assets/css/yourstyle.css'); ?>
将资产文件夹放在应用程序的根目录...
application/
assets/
system/