简体   繁体   English

CodeIgniter PHP和模板库中的Style.css

[英]Style.css in CodeIgniter PHP and Template Library

I use CodeIgniter Template and CodeIgniter PHP framework. 我使用CodeIgniter模板和CodeIgniter PHP框架。 I don't know how works metadata in this library (template). 我不知道该库(模板)中的元数据如何工作。 I try to add style.css to my layout. 我尝试将style.css添加到布局中。 In User Guide I've found info: 在用户指南中,我找到了以下信息:

 **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>');

In my layout file I have: 在我的布局文件中,我有:

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

In Controller file: 在控制器文件中:

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

It's look like good, but don't work at all. 看起来不错,但根本不起作用。

Style.css is in views/css/style.css and layout file (index.php) is in views/css/layout/index.php. Style.css在views / css / style.css中,而布局文件(index.php)在views / css / layout / index.php中。

Thanks for help! 感谢帮助!

I have found solution of my problem. 我已经找到解决问题的方法。

Step1: In .htcaccess file I added 'CSS' to RewtireCond 步骤1:在.htcaccess文件中,我向RewtireCond添加了“ CSS”

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

Step2: I created 'Assets' folder next to 'system' / 'application' folder 步骤2:我在“系统” /“应用程序”文件夹旁边创建了“资产”文件夹

Step3: I have used this commend 第三步:我用了这个表彰

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM