By Kutakizukari on
For Drupal 7 how do I get this stylesheet to only load for the page front-anonymous? https://gist.github.com/4371278
<?php
function v5tfusion_preprocess_html(&$variables) {
drupal_add_css('/css/front-anonymous.css', array('type' => 'external'));
}
?>
Comments
Would this work?
Looking at the api a little I came up with this:
If I put this code in template.php, the stylesheet front-anonymous.css should only load when viewing the page at http://example.com/front-anonymous?
Another way to do an if
Another way to do it, using a normal if statement to check your arg(0) or arg(1), depends on how your paths are structured, if front-anonymous is actually a node then you need to check if arg(0) == 'node' && arg(1) == , if its a page, arg(0) == 'front-anonymous' would be enough.
Read more about the arg function
So this is also vaild?
@Valor
So this:
Is also valid?
When I tried: <?phpif
When I tried:
It returned:
When I tried:
All I got was a blank page after flushing the cache.
I do have the php closing tag ?> removed from the template.php file.
Any help of what to try or where I'm going wrong?
You are missing the closing )
You are missing the closing ) in the if statement
Where in template.php are you placing this? Inside which function?
Ah, I assumed the closing )
Ah, I assumed the closing ) tag got auto typed in my editor. Will retry later on today.
Just placing it as is the way you see it within template.php. Is that wrong to do?
Make sure your if statement
Make sure your if statement is inside template_preprocess_html function