How to include css file for a specific view?
How can I include a css file only for a specific view in FuelCMS? Something along the lines of:
if (!empty($is_blog)):
echo css('blog').css($css);
endif;
If this is possible, where should I set the $is_blog variable so that it's recognized in the header.php block?
Comments
<?php if (!empty($css)) : echo css($css); endif; ?>
In your specific view file you can use fuel_set_var at the top of your view file:
<?php fuel_set_var('css', 'mycss')?>
I can't seem to find the relevant document in the user guide section.
And also please tell me what is 'mycss' in your code. Is it the name of a css file? What about its path?
Thank you
Then in you view file, you add the fuel_set_var code (second piece of code above) at the top. This will set the variable with the name of "css" to be "mycss". Does that help.
1- Is the "css()" function documented anywhere in the user guide? If yes, where? and if no, why?
2- I understand the meaning of css($css). But what's the meaning of "css('blog').css($css)"? This piece of code is found in the default header file installed by fuelcms.
Kind regards.
There is an 'echo' missing in your code. It should be this:
http://docs.getfuelcms.com/helpers/asset_helper#func_css
http://docs.getfuelcms.com/libraries/asset
Regarding:
echo css('main').css($css);
The css function simply outputs a link tag and so this is just concatenating them and outputing the string as opposed to 2 separate echo calls.