开发者

Drupal menu or taxonomy?

开发者 https://www.devze.com 2023-02-12 15:15 出处:网络
i have a hierarchical list of organizations and a module that performs actions to an organization. my task is to build a page where a menu tree of organizations is placed on the left side and the modu

i have a hierarchical list of organizations and a module that performs actions to an organization. my task is to build a page where a menu tree of organizations is placed on the left side and the module is on center. what is the best way to implement this?

my current suggestion is to make links in the form of "organization开发者_如何学Python/$orgid" and make the module hook_menu() wildcards. but the problem is that i can't assign wildcard paths when creating a menu item.

maybe i should use taxonomy?


You could use taxonomy for the organizations and use the following modules:

  • taxonomy_menu to generate menu items automatically for the taxonomy tree.
  • menu_block to render the menu items in different ways
  • views to manipulate the output

Using the *hook_taxonomy_menu_path* you can control what paths the menu items use that get generated using the *taxonomy_menu* module.

<?php

function mymodule_taxonomy_menu_path() {
  $output = array(
                  'mymodule_path_organizations' => t('Organization'),
                 );

  return $output;
}

function mymodule_path_organizations($vid, $tid) {
  if ($tid == 0) {
    //get all of the terms for the vocab
    $vtids = _taxonomy_menu_get_terms($vid);
    $end = implode(' ', $vtids);
    $path = "taxonomy-orgs/term/$end";
  }
  else {
    $path = 'taxonomy-orgs/term/' . $tid;
  }

  return $path;
}
0

精彩评论

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