There are a couple ways you can do that. First, it sounds like you'll need a variable that you can use to manipulate the media type for the CSS file you want to include-- let's call it $css_type. To specify that variable, you can use a variables file as shown below (example is using a views/_variables/company.php variables file):
// would apply to all pages within a particular URI segment of "company"
$vars['css_type'] = 'print';
// would apply to only the company/about page
$pages['company/about'] = array('css_type' => 'print'); More on specifying variables using the "opt-in controller" method can be found here: http://www.getfuelcms.com/user_guide/general/opt-in-controllers
Another method for creating that variable, and one that works well if you are using static view files is to use the fuel_set_var() function at the the top of your view file:
// company/about view file
fuel_set_var('css_type', 'print');<code>
Then in your header you can add something like this:
<code><?=css($css, NULL, array('attrs' => 'media="'.$css_type.'"')?> You may need to make a check for the existence of the $css_type or you can simply add it as an empty value in your global.php variables file: $vars['css_type'] = '';
Comments
http://www.getfuelcms.com/user_guide/libraries/asset
My problem: I need to set different print only css files for different pages.
Thanks.
// would apply to all pages within a particular URI segment of "company" $vars['css_type'] = 'print'; // would apply to only the company/about page $pages['company/about'] = array('css_type' => 'print');
More on specifying variables using the "opt-in controller" method can be found here: http://www.getfuelcms.com/user_guide/general/opt-in-controllersAnother method for creating that variable, and one that works well if you are using static view files is to use the fuel_set_var() function at the the top of your view file:
// company/about view file fuel_set_var('css_type', 'print');<code> Then in your header you can add something like this: <code><?=css($css, NULL, array('attrs' => 'media="'.$css_type.'"')?>
You may need to make a check for the existence of the $css_type or you can simply add it as an empty value in your global.php variables file:
$vars['css_type'] = '';