[support] Different stylesheet based on path

KOBA | Hans Rossel info at koba.be
Sun Jun 29 18:15:43 UTC 2008


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/ ]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20080629/18cd7ec4/attachment.htm 


More information about the support mailing list