【问题标题】:Style.css in CodeIgniter PHP and Template LibraryCodeIgniter PHP 和模板库中的 Style.css
【发布时间】: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


【解决方案1】:

我找到了解决问题的方法。

第 1 步:在 .htcaccess 文件中,我将“CSS”添加到 RewtireCond

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

第 2 步:我在“系统”/“应用程序”文件夹旁边创建了“资产”文件夹

Step3:这个推荐我用过

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-20
    • 2013-05-03
    • 1970-01-01
    • 1970-01-01
    • 2017-11-20
    相关资源
    最近更新 更多