CodeIgniter Forums
How to link external css files in codeigniter 2.0 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: How to link external css files in codeigniter 2.0 (/showthread.php?tid=32467)

Pages: 1 2


How to link external css files in codeigniter 2.0 - El Forum - 07-24-2010

[eluser]mi6crazyheart[/eluser]
Hello peoples,
Just recently i've download CI 2.0 & trying to use it now. Every things are fine except one thing... that, i can able to link external css file in VIEW files.

In CI 1.7.2 i was using this for link my external CSS files.
Code:
<link rel="stylesheet" href="<?php echo base_url(); ?>system/application/views/css/reset.css" />

But, as in CI 2.0 there is a small change in application folder. So, i tried this following line to link my external file. But, it's not working.
Code:
<link rel="stylesheet" href="<?php echo base_url(); ?>application/views/css/reset.css" />

My Controller file is this...
Code:
<?php

class Welcome extends Controller {

    function Welcome()
    {
        parent::Controller();
        $this->load->library('session');
        $this->load->helper('url');    
    }
    
    function index()
    {
        //$this->load->view('welcome_message');
        $this->load->view('welcomePage2');
    }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */


So Guys, is any body who r now using CI 2.0 can help me little bit to figure out the problem...

Thx in Advance... :coolsmile:


How to link external css files in codeigniter 2.0 - El Forum - 07-24-2010

[eluser]Atik[/eluser]
if u put the css file in to root folder then write the code like this
<link rel="stylesheet" href="<?php echo base_url(); ?>css/reset.css" />
i think it will be works.....


How to link external css files in codeigniter 2.0 - El Forum - 07-24-2010

[eluser]mi6crazyheart[/eluser]
@Atik...
Thx for response & i want to say u'r suggestion is working. But, i really want to know why my earlier method is not working, where i was keeping all my css files inside that VIEW folder.

Whether i'm doing some thing wrong at somewhere or now hence forward in CI 2.0 it has made been rule to keep all extra file(CSS/JavaScript) in root folder...


How to link external css files in codeigniter 2.0 - El Forum - 07-24-2010

[eluser]Ben Parizek[/eluser]
My guess why that doesn't work is because the view folder is inside the system folder and it's probably bad practice to link to anything in there from the client side. Can anybody explain this in better detail, I've always wondered what the deeper explanation for this was as well.


How to link external css files in codeigniter 2.0 - El Forum - 07-24-2010

[eluser]mi6crazyheart[/eluser]
@Ben...
Hi Ben. Actually i'm getting problem in CI 2.0 where that "application" folder is in root. But, in CI 1.7.2 it was inside of "system" folder where i'm not getting any error.

OK this is the, VIEW folder path structure from root...

In case of
-----------
CI-1.7.2 : "system/application/views/css/reset.css" [I'm not getting any error at here]
CI-2.0 : "application/views/css/reset.css" [Here "application" folder is in root folder & it is the place where i'm getting problem]

Plz Guys, if any body have any idea regarding this drop some light on this issue...


How to link external css files in codeigniter 2.0 - El Forum - 07-24-2010

[eluser]haydenk[/eluser]
Curious...

Where is this CodeIgniter 2.0 first of all?

Second, can someone explain where or what the "extenal css" is? From my point of view you're only using internal, as in it's within your own domain, external would be if you loaded it from another server, in which case link_tag() would take care of it for you.


How to link external css files in codeigniter 2.0 - El Forum - 07-24-2010

[eluser]Twisted1919[/eluser]
Jeeezzz.
Short , if you load the page and then you look into the source, you see your site url pointing to that css file . Copy that into your browser, and see if the css loads. If it does, then you have no problem. If it doesn't, it means you did a mistake when writing the path to the css file so correct it .
Other explanation, would be that, you somehow , using htaccess deny the access to the application folder (which i don't think u do)


How to link external css files in codeigniter 2.0 - El Forum - 07-24-2010

[eluser]mi6crazyheart[/eluser]
[quote author="haydenk" date="1280022869"]Curious...

Where is this CodeIgniter 2.0 first of all?

Second, can someone explain where or what the "extenal css" is? From my point of view you're only using internal, as in it's within your own domain, external would be if you loaded it from another server, in which case link_tag() would take care of it for you.[/quote]

Know more about CI 2.0 : http://philsturgeon.co.uk/news/2010/03/codeigniter-2
Type of style sheet: http://webdesign.about.com/od/css/qt/aatypesofcss.htm


How to link external css files in codeigniter 2.0 - El Forum - 07-24-2010

[eluser]mi6crazyheart[/eluser]
@Twisted1919...
I follow u'r trick & i got "403 forbidden error". :cheese:

Oh no. What's d hell this is going on. :red: . In hosting server it's very easy to change (graphically) file access permission. But, in localhost... :down: (not so much comfortable in Ubuntu terminal)

In CI 1.7.2 i've no such kind of problem but in CI 2.0 it's showing. Ok let me see what can i do... Undecided


How to link external css files in codeigniter 2.0 - El Forum - 07-25-2010

[eluser]Phil Sturgeon[/eluser]
They moved application folder outside of system folder in 2.0 a while ago and added some .htaccess rules to restrict that sort of thing.

There is no reason to add your assets in the view folder, put them in the root.