我一直试图让我的Drupal 6模块定制方式分类项的网页显示在一定条件下。这很容易通过主题来完成,但也有不似乎是经由模块实现这个的一个简单方法。

一个很好的协议审判,错误和谷歌搜索后,我想出了解决这个问题的方式如下:

这似乎运作良好,并的感觉的比替代解决方案,我发现网上哈克要少得多。但是,我担心的是,我没有看到在许多Drupal的论坛页面的任何地方这个例子 - 它让我觉得,可能有一些可怕的错误与此解决方案,我还没有看到

可以在任何SO'er看问题,用此溶液,或(更好的)建议,可以建立在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);
    }
}
有帮助吗?

解决方案

如何使用hook_menu_alter()代替hook_menu()的?这样,这种分类以明确的方式产生,而不必担心模块的重量和哪个项目被添加最后你可以改变的菜单项。

否则,这就是我怎么会做这样的事情在一个模块内容。

其他提示

看一看content.module或views.module,看看它是如何实现在那里,如果您安装了。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top