Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By ultimante on
Is there a $variable that contains the current theme name that would be available to page.tpl.php?
The reason I ask is because I want to have custom page layout css files within a single theme, and the easiest way I can think of doing that is by making css files and putting them inside a folder named after the current theme, so that when the user changes the theme, it will load in the custom css layouts for that specific page within the current theme.
Thanks!
Comments
Not sure
I'm not exactly sure what you're trying to achieve. But when you want to modify an existing template only by css, you can put a new style.css in a subfolder of the theme. Drupal will automatically detect this new style as a new theme.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.
slightly different way
If you click through to this handbook page: http://drupal.org/node/46024
It explains how to insert unique BODY Classes & IDs for your pages in your page.tpl.php files, so you can pull up custom styles within your style sheets within the same theme.
An example application might be for adjusting a fixed width layout when you use the administrative options.
Using this snippet, when you go to to admin/themes, for example, you may use the following style hooks in your style sheet to control how the full page looks.
<body class="section-admin" id="page-admin-themes">
In your style sheet (the CSS file in your active theme folder), you simply add another line to change the layout when you click on the ADMINISTER menu:
I hope that helps and the handbook page is easy to follow. It doesn't go into the detail of HOW it works..it's just a step by step.
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
Dead link
node/46024 does not appear to exist
Here's a variable
The global variable $theme_key gives you the name of your theme.
If you want more theme info, you can use the function list_themes() (defined in includes/theme.inc) to get a list of available themes, and then use the global variable $theme_key to get your them object like this:
Thanks, this helped me... ;)
Thanks, this helped me... ;) As I understand that using this variable could be a result of a badly thought solution, here's my case :
I want to add specific icons to each node depending on there types, but this must be themable, so I want to fetch icons in the "images/" in the theme directory first... then fallback on a default icon provided by the module.
To create the valid "img" tag, and fill its "src" attribute, I must access the path of the current path...
Is there a best way to achieve the same goals ?
Before themes are loaded...
If you need to access before themes are loaded.
The current theme path
If you need the path of the current theme then just use drupal_get_path('theme', 'theme_key'). See http://api.drupal.org/api/function/drupal_get_path/ .
Can't you just use the
Can't you just use the path_to_theme() function, and from there infer the current theme ?
I was looking for a better solution, and ran across this thread : Just my two cents then...
<?phpglobal $theme;?> or
or directly:
Thanks
Thanks