开发者

Drupal - print the current/active sub theme

Im trying to get the path to the current theme (w开发者_Go百科hich is a sub theme) but I am having issues.

I have seen these 2 sites:

http://venutip.com/content/getting-path-your-subtheme
http://www.website-assistant.co.uk/web-developer/path-subtheme-drupal

Which has led me to this: (as an example)

template.php

function phptemplate_preprocess_node(&$vars) {
 global $theme_key;
 $path_to_theme = drupal_get_path('theme', $theme_key);
}

?>

page.tpl

<link rel="stylesheet" href="/<?php print $path_to_theme; ?>/css/print.css" media="print" type="text/css" />

But it doesnt work. What am I missing? I am using Drupal 6.19.

A.


In your phptemplate_preprocess_node function, you need to add the $path_to_theme variable to the $vars array:

function phptemplate_preprocess_node(&$vars) {
  global $theme_key;
  $vars['path_to_theme'] = drupal_get_path('theme', $theme_key);
} 

You are also able to add print CSS via the theme's .info file by adding a line like this:

stylesheets[print][] = css/print.css

The advantage of this approach is that your CSS files will be aggregated properly when CSS aggregation is enabled.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜