Ste*_*ble 24 drupal drupal-6 drupal-theming
Drupal API具有drupal_get_path($type, $name)
任何特定主题或模块的路径.如果我想要当前主题的路径怎么办?
FGM*_*FGM 25
使用该path_to_theme
功能.
Owe*_*wen 20
这应该工作(doc):
global $theme;
$path = drupal_get_path('theme', $theme);
// there's also a $theme_path global
global $theme_path;
Run Code Online (Sandbox Code Playgroud)
小智 10
在D6中,path_to_theme()可能不会以您期望的方式运行,具体取决于您使用它的方式.如果你在任何主题预处理函数之外使用它,那么它可能会给你你想要的东西,但是如果在模块的主题/预处理钩子函数的上下文中调用它...它将指向模块路径宣布主题.
防爆.如果我有一个主题"my_theme"和我的模块"my_module"使用预处理挂钩覆盖论坛主题,则在我的模块中调用path_to_theme():例如my_module_preprocess_forums()...将返回"论坛",而不是"my_theme" "正如人们所预料的那样.
如果你问我,果味很浓.
小智 10
在 Drupal 8 中,如果您需要在管理主题处于活动状态时获取活动主题路径,您可以获取默认主题路径:
$themeHandler = \Drupal::service('theme_handler');
$themePath = $themeHandler->getTheme($themeHandler->getDefault())->getPath();
Run Code Online (Sandbox Code Playgroud)
小智 5
在 Drupal 8 中
global $base_url;
$theme = \Drupal::theme()->getActiveTheme();
$image_url = $base_url.'/'. $theme->getPath() .'/images/image.jpg';
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
48978 次 |
最近记录: |