1

I have problem with css file in CodeIgniter framework. In my autoconfig file I load url and html helper. In view I have code:

<?php echo link_tag('application/assets/css/style.css')?>

but this code doesn't work. In config file my base_url is http://localhost/CI. My directory structure is

-application -assets -css -views -partials -home I try

<link rel="stylesheet" type="text/css" href="<?=base_url()?>application/assets/css/style.css"/> 

or

<link rel="stylesheet" type="text/css" href="<? echo base_url('application/assets/css/style.css')?>"/>

but this also doesn't work.

3
  • 1
    You can't put your asset folder in application folder. Commented Aug 31, 2016 at 9:47
  • So assets folder must be in root directory? Commented Aug 31, 2016 at 9:48
  • move assets outside the applciation Commented Aug 31, 2016 at 9:49

3 Answers 3

2

Put your asset folder in project root, out side application folder.

Change the link to,

<?php echo link_tag('assets/css/style.css')?>

CI Folder Structure

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, this work. I put assets folder in application folder because I read it in the course.
1

You need to use assets folder outside the application folder, something like:

enter image description here

Than you can call like:

<?php echo link_tag('assets/css/style.css');?>

2 Comments

But should enable the helper in autoload.php file in config folder. $autoload['helper'] = array('url','form','security','html');
@Tamilheartz: yes agreed
0

I think you do not remove index.php from url so you should set address for css like this :

<?php echo site_url('assets/css/style.css')?>

Comments

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.