I'm running a site with Drupal 6.2 that will have many different sections to the site.
Is there a way to define a stylesheet based on path? Sections does a great job defining themes based on path, but that only let's you choose a different theme. I'd love something exactly like that, but with the ability to just choose a different stylesheet. Many of the sections on my site will just use a different header graphic. I'd rather not duplicate the template, just serve it a different stylesheet.
Is there a way to do this?
- jody
I've not built a theme for Drupal 6 yet but in Drupal 5 what you can do is add a body class based on what's in arg(). This can be done in template.php.
psynaptic http://freestylesystems.co.uk http://api.freestylesystems.co.uk
On 25 Jun 2008, at 23:42, Jody Cleveland wrote:
I'm running a site with Drupal 6.2 that will have many different sections to the site.
Is there a way to define a stylesheet based on path? Sections does a great job defining themes based on path, but that only let's you choose a different theme. I'd love something exactly like that, but with the ability to just choose a different stylesheet. Many of the sections on my site will just use a different header graphic. I'd rather not duplicate the template, just serve it a different stylesheet.
Is there a way to do this?
- jody
-- [ Drupal support list | http://lists.drupal.org/ ]
On 6/25/08 5:45 PM, "Richard Burford" rich@freestylesystems.co.uk wrote:
I've not built a theme for Drupal 6 yet but in Drupal 5 what you can do is add a body class based on what's in arg(). This can be done in template.php.
I tried adding this to template.php, but it didn't seem to do anything (body tag still shows up as just <body>:
print '<body id="'. arg(0) .'" '; print theme('onload_attribute'); print ">";
Do I have that right?
- jody
Jody Cleveland wrote:
On 6/25/08 5:45 PM, "Richard Burford" rich@freestylesystems.co.uk wrote:
I've not built a theme for Drupal 6 yet but in Drupal 5 what you can do is add a body class based on what's in arg(). This can be done in template.php.
I tried adding this to template.php, but it didn't seem to do anything (body tag still shows up as just <body>:
print '<body id="'. arg(0) .'" '; print theme('onload_attribute'); print ">";
Do I have that right?
- jody
What you have there should work.
Alternatively, if you want to use different css files based on path, you can do something like this at the top of template.php:
switch (arg(0)) { case 'admin': drupal_add_css(path_to_theme() .'/admin.css', 'theme', 'all'); break; case 'somethingelse': drupal_add_css(path_to_theme() .'/another-css-file.css', 'theme', 'all'); break; }
Cheers,
Jonathan
On 6/25/08 6:18 PM, "Jonathan Hedstrom" jhedstrom@opensourcery.com wrote:
Jody Cleveland wrote:
On 6/25/08 5:45 PM, "Richard Burford" rich@freestylesystems.co.uk wrote:
I've not built a theme for Drupal 6 yet but in Drupal 5 what you can do is add a body class based on what's in arg(). This can be done in template.php.
I tried adding this to template.php, but it didn't seem to do anything (body tag still shows up as just <body>:
print '<body id="'. arg(0) .'" '; print theme('onload_attribute'); print ">";
Do I have that right?
- jody
What you have there should work.
Alternatively, if you want to use different css files based on path, you can do something like this at the top of template.php:
switch (arg(0)) { case 'admin': drupal_add_css(path_to_theme() .'/admin.css', 'theme', 'all'); break; case 'somethingelse': drupal_add_css(path_to_theme() .'/another-css-file.css', 'theme', 'all'); break; }
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
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/ ]
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/ ]
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@gmail.com wrote:
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/ ]
I was aquainted with that technique in this forum discussion:
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@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@gmail.com wrote:
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/ ]
-- 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/ ]
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@gmail.com wrote:
I was aquainted with that technique in this forum discussion:
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@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@gmail.com wrote:
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/ ]
-- 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/ ]
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@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@gmail.com wrote:
I was aquainted with that technique in this forum discussion:
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@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@gmail.com wrote:
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/ ]
-- 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/ ]
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@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@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@gmail.com wrote:
I was aquainted with that technique in this forum discussion:
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@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@gmail.com wrote:
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/ ]
-- 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/ ]
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@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@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@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@gmail.com wrote:
I was aquainted with that technique in this forum discussion:
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@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@gmail.com wrote:
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/ ] >
-- 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/ ]
One way I've seen it done make a region in your template for the banner, and then create a block for each different banner (where the block body is the img tag for the banner graphic). Then, in the "Show block on specific pages" fieldset, check the "Show on only the listed pages" radio button and list the URL for the page where you want that particular banner to be displayed.
Steve
Richard Burford wrote:
I've not built a theme for Drupal 6 yet but in Drupal 5 what you can do is add a body class based on what's in arg(). This can be done in template.php.
psynaptic http://freestylesystems.co.uk http://api.freestylesystems.co.uk
On 25 Jun 2008, at 23:42, Jody Cleveland wrote:
I'm running a site with Drupal 6.2 that will have many different sections to the site.
Is there a way to define a stylesheet based on path? Sections does a great job defining themes based on path, but that only let's you choose a different theme. I'd love something exactly like that, but with the ability to just choose a different stylesheet. Many of the sections on my site will just use a different header graphic. I'd rather not duplicate the template, just serve it a different stylesheet.
Is there a way to do this?
- jody
-- [ Drupal support list | http://lists.drupal.org/ ]
You could also use the header_image module if it is just the header that needs to be changed with the path.
Or if you stick to sections you could make subthemes where only the css is different.
Hans www.koba.be
2008/6/26, Steve Edwards killshot91@comcast.net:
One way I've seen it done make a region in your template for the banner, and then create a block for each different banner (where the block body is the img tag for the banner graphic). Then, in the "Show block on specific pages" fieldset, check the "Show on only the listed pages" radio button and list the URL for the page where you want that particular banner to be displayed.
Steve
Richard Burford wrote:
I've not built a theme for Drupal 6 yet but in Drupal 5 what you can do is add a body class based on what's in arg(). This can be done in template.php.
psynaptic http://freestylesystems.co.uk http://api.freestylesystems.co.uk
On 25 Jun 2008, at 23:42, Jody Cleveland wrote:
I'm running a site with Drupal 6.2 that will have many different sections to the site.
Is there a way to define a stylesheet based on path? Sections does a great job defining themes based on path, but that only let's you choose a different theme. I'd love something exactly like that, but with the ability to just choose a different stylesheet. Many of the sections on my site will just use a different header graphic. I'd rather not duplicate the template, just serve it a different stylesheet.
Is there a way to do this?
- jody
-- [ Drupal support list | http://lists.drupal.org/ ]