[support] Different stylesheet based on path

KOBA | Hans Rossel info at koba.be
Wed Jul 2 02:26:53 UTC 2008


Great you have found it.

Themes like Minellii are called subthemes, which I proposed in the
beginning of this thread as an option. Sorry for not having been clear
enough.

Hans

2008/7/1, Jody Cleveland <cleveland at winnefox.org>:
> I actually ended up finding a completely different way of doing this, and it
> works great.
>
> The owner of the fabulous Sections module mentioned to me that the Garland
> theme that ships with Drupal actually kind of does this with the Minnelli
> theme. It's basically a folder inside of Garland that has a css file and an
> info file. You can also have a screenshot and logo file.
>
> But, this way, I can use the sections module to specify which theme based
> off the main that I want for various taxonomy.
>
> - jody
>
>
> On 6/30/08 10:25 PM, "Cog Rusty" <cog.rusty at gmail.com> wrote:
>
>> What do you mean wildcards? Do you mean checking only the first part
>> of an aliased path? Probably yes. I just added an (untested)
>> suggestion in that forum thread:
>>
>> http://drupal.org/node/271818#comment-902933
>>
>> Not sure if you already tried the same thing and didn't work.
>>
>>
>>
>> On Tue, Jul 1, 2008 at 2:09 AM, Jody Cleveland <cleveland at winnefox.org>
>> wrote:
>>> I will do that, thank you.
>>>
>>> I was able to get it to work for the front page, but I haven't been able
>>> to
>>> get it working for any internal pages. Will that code work with wild
>>> cards
>>> at all?
>>>
>>>
>>> On 6/30/08 11:37 AM, "Cog Rusty" <cog.rusty at gmail.com> wrote:
>>>
>>>> I was aquainted with that technique in this forum discussion:
>>>>
>>>> http://drupal.org/node/271818
>>>>
>>>> Maybe you could message the guy who finally seemed to succeed in doing
>>>> that.
>>>>
>>>>
>>>>
>>>> On Mon, Jun 30, 2008 at 7:15 PM, Jody Cleveland <cleveland at winnefox.org>
>>>> wrote:
>>>>> I just can't seem to get this to work... I've tried this:
>>>>>
>>>>> function salamander_preprocess_page(&$variables) {
>>>>>  $front_style = path_to_theme() .'/front-page.css';
>>>>>  $path_style = path_to_theme() .'/path-'. arg(0) .'.css';
>>>>>
>>>>>  if (file_exists($front_style) && $variables['is_front']) {
>>>>>    $include_style = $front_style;
>>>>>  }
>>>>>  elseif (file_exists($path_style)) {
>>>>>    $include_style = $path_style;
>>>>>  }
>>>>>
>>>>>  if (isset($include_style)) {
>>>>>    drupal_add_css($include_style, 'theme', 'all', FALSE);
>>>>>    $variables['styles'] = drupal_get_css();
>>>>>  }
>>>>> }
>>>>>
>>>>> Cleared the site cache, refreshed pages, and I don't see anything added
>>>>> to
>>>>> the header. I'm guessing there should be something like:
>>>>> <link type="text/css" rel="stylesheet" media="all"
>>>>> href="/sites/beta.menashalibrary.org/themes/salamander/path-xxx.css" />
>>>>>
>>>>> I also tried this:
>>>>>
>>>>>  //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];
>>>>>
>>>>> And, when I view the source, I don't see anything containing node/xxx
>>>>>
>>>>> So, I'm really stumped. I am supposed to be adding these to
>>>>> template.php of
>>>>> the theme I'm using, right? Basically, I want all page urls that are
>>>>> teens/*
>>>>> to use the teens.css file I have in my theme.
>>>>>
>>>>> - jody
>>>>>
>>>>>
>>>>> On 6/29/08 5:33 PM, "Cog Rusty" <cog.rusty at gmail.com> wrote:
>>>>>
>>>>>> For Drupal 6, see also this for how to add stylesheets to a theme's
>>>>>> .info
>>>>>> file
>>>>>>
>>>>>> http://drupal.org/node/171209
>>>>>>
>>>>>> and this for a more versatile method for adding path-based
>>>>>> stylesheets:
>>>>>>
>>>>>> http://drupal.org/node/225868
>>>>>>
>>>>>> 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 at 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/ ]
>>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Jody Cleveland
>>>>>
>>>>> "It's because I take you so seriously that I can't bring myself to
>>>>> believe
>>>>> in you."
>>>>> - Julia Sweeney ~ Letting Go of God
>>>>>
>>>>> --
>>>>> [ Drupal support list | http://lists.drupal.org/ ]
>>>>>
>>>
>>>
>>> --
>>> Jody Cleveland
>>>
>>> "It's because I take you so seriously that I can't bring myself to
>>> believe
>>> in you."
>>> - Julia Sweeney ~ Letting Go of God
>>>
>>> --
>>> [ Drupal support list | http://lists.drupal.org/ ]
>>>
>
>
> --
> Jody Cleveland
>
> "The invisible and the non-existent often look very much alike."
> - Julia Sweeney ~ Letting Go of God
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>


-- 
Hans Rossel
KOBA Webdevelopment
Kerkstraat 228
9050 Gent
09-334.52.60
0472-79.32.16
www.koba.be
info at koba.be


More information about the support mailing list