我使用CodeIgniter模板和CodeIgniterPHP框架。我不知道这个库(模板)中的元数据是如何工作的。我尝试将style.css添加到我的布局中。在用户指南中,我找到了信息:
**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>
在控制器文件中:
$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)在view/css/layout/index.php.中
谢谢你的帮助!
我找到了问题的解决方案。
步骤1:在.htaccess文件中,我将"CSS"添加到RewterCond
RewriteCond $1 !^(index'.php|images|robots'.txt|css)
步骤2:我创建了"系统"/"应用程序"文件夹旁边的"资产"文件夹
步骤3:我使用了这个赞扬
->prepend_metadata('<link rel="stylesheet" href="'.base_url("assets/css/style.css").'" type="text/css" media="all" />')