0

I use CodeIgniter Template and CodeIgniter PHP framework. I don't know how works metadata in this library (template). I try to add style.css to my layout. 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.

Thanks for help!

3
  • Try using href='<?=base_url()?>css/style.css' Commented Sep 1, 2014 at 14:42
  • base_url() + '/directory/path/to/css' or base_url('directory/path/to/css')
    – tomexsans
    Commented Sep 1, 2014 at 17:48
  • I tired base_url("application/views/css/style.css") or base_url()?>css/style.css and nothing ;/ Commented Sep 1, 2014 at 21:03

1 Answer 1

0

I have found solution of my problem.

Step1: In .htcaccess file I added 'CSS' to RewtireCond

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

Step2: I created 'Assets' folder next to 'system' / 'application' folder

Step3: I have used this commend

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.