Welcome Guest, Not a member yet? Register   Sign In
how to load the css from view
#1

[eluser]sureshls[/eluser]
Hi,

I have my styles & script into view folder. The folder structure will be

../applications/views/admin_temp/default/assets/css/admin_style.css
../applications/views/admin_temp/temp1/assets/css/temp_style.css

now, i need to call/ apply the style (admin_style.css or temp_style.css) in my view files. How to do that?

Thanks





#2

[eluser]tauruss[/eluser]
Generally, css should be not in views folder, but outside of application folder.
For example, you can create a "css" folder in your main folder (where index.php is stored),
and then use function link_tag from HTML Helper in your view,
just like in example in manual

http://ellislab.com/codeigniter/user-gui...l#link_tag
#3

[eluser]sureshls[/eluser]
Thanks Tauruss, but i have few templates in view folder also. Like template for admin login & template for user login. Even i have the css file outside the application folder. I have to call both css. How to do that?

Thanks
#4

[eluser]Aken[/eluser]
Load it with a <link> tag, like you would any CSS file...
#5

[eluser]jairoh_[/eluser]
<link rel="stylesheet" href="that path" /> Big Grin
#6

[eluser]tauruss[/eluser]
As I said before, you can use link_tag() function, or just simply <link> tag in your html document with template.
But why do you want load both of them ? Maybe I understood you wrong, but you said, that you have two css files, one for admin pages, second for users pages.
You shouldn't load css, if it is not necessary. You can avoid this by passing to the view variable with proper css file, for example:
pass to view variable $css, with filename of css (user.css / admin.css) depending which one should be used,
and then in view You use link_tag()

Code:
$link = array(
          'href' => 'css/' . $css ,
          'rel' => 'stylesheet',
          'type' => 'text/css',
          'media' => 'print'
);

echo link_tag($link);




Theme © iAndrew 2016 - Forum software by © MyBB