代码之家  ›  专栏  ›  技术社区  ›  anschauung

请检查愚蠢:在Drupal中自定义分类术语页面

  •  2
  • anschauung  · 技术社区  · 16 年前

    我一直在尝试让我的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);
        }
    }
    
    2 回复  |  直到 16 年前
        1
  •  4
  •   John Fiala    16 年前

    hook_menu_alter() hook_menu()

    否则,我会在模块上下文中这样做。

        2
  •  0
  •   arieltools    15 年前