CodeIgniter Forums
Auto Load CSS - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Auto Load CSS (/showthread.php?tid=15565)

Pages: 1 2


Auto Load CSS - El Forum - 02-08-2009

[eluser]Light North Media[/eluser]
Hello Everyone,

I am having trouble autoloading my css styles. I would like to CI to have a style sheet that would be used for all of my views and automatically be applied using the autoloader. here is what I have

$autoload['externals'] = array('style');

my folder "extertnals" is in the application directory and inside "external" is "style.css" but nothing is working.

Can you tell me what I am doing wrong?

Thanks


Auto Load CSS - El Forum - 02-08-2009

[eluser]TheFuzzy0ne[/eluser]
I'm not sure where you got $autoload['externals'] from. The autoloader can only load any of the following:

1. Libraries
2. Helper files
3. Plugins
4. Custom config files
5. Language files
6. Models

and those files must be in the right format.

A stylesheet does not fit into any of those. You would normally link to a CSS document from within your view using <link /> tags.


Auto Load CSS - El Forum - 02-08-2009

[eluser]Light North Media[/eluser]
Ah, thank you, I was under the impression that the autoloader could load most anything.

Is there any possible way that I could have a stylesheet be loaded for every view without manually entering it in each view?


Auto Load CSS - El Forum - 02-08-2009

[eluser]darkhouse[/eluser]
I wrote a library that does this. Coincidentally I called it External. It allows you to load everything from css and javascript files to code snippets to IE specific items. It uses a config file that allows you to setup anything you want for various routes. It also has a couple reserved settings like 'all' for applying certain items to every page, and 'default' which it will use if it can't find any files for a specific route.

Here's the link [url="http://ellislab.com/forums/viewthread/101236/"]http://ellislab.com/forums/viewthread/101236/[/url]


Auto Load CSS - El Forum - 02-08-2009

[eluser]Light North Media[/eluser]
Hey,

Thanks for all your help!


Auto Load CSS - El Forum - 02-08-2009

[eluser]bobbob[/eluser]
I just put:
$config['css'] = "mystyles.css";
in my config.php and te mystyles is in the root.
It is available to every page on the site.
Might be a simpler way


Auto Load CSS - El Forum - 02-08-2009

[eluser]Light North Media[/eluser]
Hello bob,


I tried what you suggested and it didnt work, do you have more detailed instructions?


Auto Load CSS - El Forum - 02-08-2009

[eluser]bobbob[/eluser]
in application/config/config.php is where you put the:
$config[‘css’] = “mystyles.css”;
I put it directly under $config['base_url']

Then just put the css file in the same directory as system:

index.php
mystyles.css
system/Application/controllers
user_guide

The above being a sort of representation of the directory.
Does that help?


Auto Load CSS - El Forum - 02-08-2009

[eluser]Light North Media[/eluser]
Thank you, I will try it out!


Auto Load CSS - El Forum - 02-08-2009

[eluser]Light North Media[/eluser]
Hmm, did you define anything in your controllers because with the exact setup that I have, it isnt working...Also, I am using version 1.7 if that makes a difference.