开发者

Drupal template overwrite

开发者 https://www.devze.com 2023-02-11 20:53 出处:网络
One template which is output by a tpl.php template file in hook_theme (eg:book-navigation.tpl.php). Could i use the preprocess function to ov开发者_运维知识库erwrite it in my theme file template.php?I

One template which is output by a tpl.php template file in hook_theme (eg:book-navigation.tpl.php). Could i use the preprocess function to ov开发者_运维知识库erwrite it in my theme file template.php? If I can, could you give me an example of how to do it?


Add this code into template.php:

function phptemplate_preprocess_book_navigation(&$vars) {
  if (WRITEHERE_YOUR_CONDITION_WHEN_YOU_WANTTO_CHANGE_TEMPLATE) {
    $vars['template_files'][]  = 'book-navigation-spec';
  }
}

Copy book-navigation.tpl.php to your theme folder.
create book-navigation-spec.tpl.php (take source from first file), and write your changes.
Clear cache.

0

精彩评论

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