Hi, I created a patch to the "taxonomy" module which adds a new operator, "up", to the existing ones. Instead of the URL "taxonomy/view/or/17" you can use "taxonomy/view/up/17" and the nodes from term (tid) #17 **and all of its parents** are displayed.

Fortunately most of the processing already exists, so my patch is quite small. Here is the complete patch. Based on Drupal 4.4.1, it starts at line 667:


function taxonomy_select_nodes($taxonomy, $pager = 1) {
  global $user;

  if ($taxonomy->str_tids) {

    // new operator "up" - added 7-14-2004 - ALG
    // returns all nodes in specified vocabulary term **and all nodes in its parents**
    // converts the "up" querystring to an "or" with all parents included in the q.s.
        if ($taxonomy->operator == "up") {
          $new_str_tid = "";
          foreach ($taxonomy->tids as $a => $b) {        // for each tid we look up all parents
            $parents = taxonomy_get_parents_all($taxonomy->tids[$a]);
            foreach ($parents as $c => $d) {             // for each parent we add to string
              $new_str_tid .= $parents[$c]->tid.",";
            }
          }

          $taxonomy->operator = "or";
          $taxonomy->str_tids = rtrim($new_str_tid, ",");
          $taxonomy->tids = explode(",", $taxonomy->str_tids);
        }
    // end of new operator "up"

    if ($taxonomy->operator == "or") {

Why would you want this? For example, imagine you had a hierarchy at your company:

  • All Employees
    • Marketing
      • Europe
      • North America
        • USA
        • Canada
        • Mexico
      • Asia
    • Finance
    • Operations

If I want to create a node for all Marketing employees, I have two options... I can select every single term under Marketing in the taxonomy, or I can just place it in "Marketing" and then hope that the users check that term when they log on. By using automatically viewing all parents, the node creator can simply place the new node in "Marketing", and then when (for example) the Canadian salesperson user logs in and views the taxonomy term "Canada" he/she will automatically see the new node (since Marketing is a parent of Canada).

At my organization this kind of organization is essential for our CMS system.

Anyway my main question is, what to do now? I don't really know much about CVS. How do I submit this for review?

Thanks. Hope this patch is useful.

Comments

matt westgate’s picture

A similar issue is already being worked on. Perhaps you can help them roll out a solid patch and get it committed to the Drupal core?