Welcome Guest, Not a member yet? Register   Sign In
Including Style Sheets or JavaScript Files do View Files
#1

[eluser]Bastian Stock[/eluser]
Hi again,

can somebody tell me what is the best way to add css or JavaScript Files as an HTML Include to my View Files.

Is there an Recommanded way todo this without pasting all the content of that File in the view File?

Or should I create a external Directory outside of CI to include it with HTML?

many thx
Bastian
#2

[eluser]Michael Wales[/eluser]
The common theme around here is to create an /assets/ directory at the root of your server, with child directories for each of your assets (images, css, js, etc).

Personally, I skip the assets directory and just create an images, css, and js directory at the root level.
#3

[eluser]esra[/eluser]
You can create a view fragment (another view that is nested within a parent view). Generally this is handled by creating a master view (also called a template) and your css and js are loaded once there. Once you create the template, you can load your controller views in that template from your controllers. Some standard PHP solutions are documented on the wiki here:

http://codeigniter.com/wiki/Displaying_Multiple_Views/

The FAQ includes an area with many links to other solutions. I personally use the View library developed by Coolfactor.

Regarding storing your CSS. All paths in CI are relative to the directory where your index.php file is stored. You can follow Michaels approach or use something like the assets_helper to define directories for storing your css, js and images.
#4

[eluser]Bastian Stock[/eluser]
ohh cool thx very much I test what is the best method for me




Theme © iAndrew 2016 - Forum software by © MyBB