Drupal-打印当前/活动子主题

Drupal-打印当前/活动子主题,drupal,Drupal,我试图找到当前主题的路径(这是一个子主题),但我遇到了一些问题 我看过这两个网站: http://venutip.com/content/getting-path-your-subtheme http://www.website-assistant.co.uk/web-developer/path-subtheme-drupal 这让我想到了这一点:(作为一个例子) template.php function phptemplate_preprocess_node(&$vars) {

我试图找到当前主题的路径(这是一个子主题),但我遇到了一些问题

我看过这两个网站:

http://venutip.com/content/getting-path-your-subtheme
http://www.website-assistant.co.uk/web-developer/path-subtheme-drupal
这让我想到了这一点:(作为一个例子)

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

?>
page.tpl

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

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

在phptemplate_preprocess_节点函数中,需要将$path_to_主题变量添加到$vars数组中:

function phptemplate_preprocess_node(&$vars) {
  global $theme_key;
  $vars['path_to_theme'] = drupal_get_path('theme', $theme_key);
} 
您还可以通过添加以下行,通过主题的.info文件添加打印CSS:

样式表[print][]=css/print.css


这种方法的优点是,当启用CSS聚合时,您的CSS文件将正确聚合。

在phptemplate_preprocess_节点函数中,您需要将$path_to_主题变量添加到$vars数组中:

function phptemplate_preprocess_node(&$vars) {
  global $theme_key;
  $vars['path_to_theme'] = drupal_get_path('theme', $theme_key);
} 
您还可以通过添加以下行,通过主题的.info文件添加打印CSS:

样式表[print][]=css/print.css


这种方法的优点是,当启用CSS聚合时,您的CSS文件将被正确聚合。

谢谢您的回复,但我担心这似乎仍然不起作用。您在定义函数后重建了主题缓存了吗?另外,请参阅我的编辑,关于如何通过主题的.info文件执行此操作。谢谢您的回复,但恐怕这似乎仍然不起作用。您在定义函数后重建了主题缓存了吗?另外,请参阅我的编辑,通过主题的.info文件执行此操作