【发布时间】:2014-09-02 06:55:58
【问题描述】:
我使用CodeIgniter Template 和 CodeIgniter PHP 框架。我不知道这个库(模板)中的元数据是如何工作的。我尝试将 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)在views/css/layout/index.php 中。
感谢您的帮助!
【问题讨论】:
-
尝试使用 href='=base_url()?>css/style.css'
-
base_url()+'/directory/path/to/css'或base_url('directory/path/to/css') -
我厌倦了 base_url("application/views/css/style.css") 或 base_url()?>css/style.css 什么都没有;/
标签: php css codeigniter templates