我一直在尝试让我的Drupal 6模块在特定条件下自定义分类术语页面的显示方式。这很容易通过主题来实现,但似乎没有一种简单的方法可以通过模块来实现。
它似乎工作得很好,而且
感觉
有人能看到这个解决方案的问题吗,或者(更好地)建议一种可以在Drupal现有主题挂钩的基础上构建的方法吗?
function foo_menu() {
// other menu callbacks ...
$items['taxonomy/term/%'] = array(
'title' => 'Taxonomy term',
// override taxonomy_term_page
'page callback' => 'foo_term_page',
'page arguments' => array(2),
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
// other menu callbacks
}
function foo_term_page($str_tids = '', $depth = 0, $op = 'page') {
if ($my_conditions_are_true) {
// foo_theme_that_page is a copy-paste of taxonomy_term_page
// that includes the customizations I want
return foo_theme_that_page($str_tids,$depth,$op);
} else { //Conditions aren't met. Display term normally
module_load_include('inc', 'taxonomy', 'taxonomy.pages');
return taxonomy_term_page($str_tids,$depth,$op);
}
}