For Drupal 6, see also this for how to add stylesheets to a theme's .info file
and this for a more versatile method for adding path-based stylesheets:
Note that arg() always returns the original drupal path (such as node/nn) and not the alias, so in some cased you may need to use drupal_get_path_alias($_GET['q']) and then split it.
On Sun, Jun 29, 2008 at 9:15 PM, KOBA | Hans Rossel info@koba.be wrote:
I think you will always get "node" for arg(0) when the pages under /teens are nodes. So switch (arg(0)) { case 'teens': will never happen. It works for admin because those pages are no nodes.
To get teens when the path alias is /teens you should use
<?php //explode() will split the given string with another string and put the pieces into an array $path_pieces = explode('/', drupal_get_path_alias($_GET['q'])); //so if your path is /abc/def, $path_pieces is now like Array ( [0] => abc [1] => def ) //Therefore, $path_pieces[0] prints 'abc' that you wanted print $path_pieces[0]; ?>
See http://drupal.org/node/227849.
Good luck!
Hans www.koba.be
Still not working for me. I placed this at the top of my theme's template.php:
switch (arg(0)) { case 'admin': drupal_add_css(path_to_theme() .'/admin.css', 'theme', 'all'); break; case 'teens': drupal_add_css(path_to_theme() .'/teens.css', 'theme', 'all'); break; }
The url path I'm trying to change the css for is /teens and the css file I'm trying to use is teens.css. I've tried clearing the cache, but when I view the source of the teens page, there's no reference to teens.css. Is there something else I missed? Can I also use this with wildcards? (case 'teens/*' so that all pages within that area get that theme)
Thank you so much for your time in helping me with this.
- jody
-- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]