Hello

I installed the Taxonomy Menu - Module. The Taxonomy Terms are shown in the Navigation-menu.
Is it possible to show the links in another menu as well?

Thank you

Adriana

Comments

BobT-1’s picture

Maybe this? http://drupal.org/node/15192 I haven't tried it, yet. Let me know what you find out if you try it first, as this is something I'm also interested in. (I'm just late for work right now :) )
_________
bob-thompson.com

mikolaskova’s picture

...i tried http://drupal.org/node/15192, but it does something different...

BobT-1’s picture

Thanks for the feedback. I'll keep looking. This seems like an ordinary thing to want to do. I'll keep you posted.
_________
bob-thompson.com

bwynants’s picture

I was able to do this based on http://drupal.org/node/24989.

BobT-1’s picture

In another, similar thread I found a link to this tutorial, which clued me into the existence of theme_menu_tree(). The tutorial at the link above was meant for creating a drop down menu at the top of the site. Very cool, but not what you asked about ;). Here are the steps I used to break out certain bits of the navigation menu into separate blocks.

  • Click administer » modules and enable menu and taxonomy_menu, if they're not already.
  • Click administer » menus. Find the vocabulary you want to add to the block, hover over its edit link, and note the number at the end of the url in your status bar (there are pictures to illustrate this in the tutorial). You could also click the edit link and note the number at the end of the url in the address bar. For the sake of example let's say you want to list your Forums, as I did, and the number at the end of your forums edit link is 59, as mine is.
  • Click administer » blocks, then click the add block tab. Name the block Forums for this example, and check PHP Code as the input format.
  • In the block body type (or copy and paste)
    <?php
    $SeparateTaxonomyMenu = theme_menu_tree(59);
    print $SeparateTaxonomyMenu;
    ?>
  • Fill in the block description.
  • Click the Save Block button.
  • Click the List tab. Find your new block, check enabled, check right or left to place it where you want it, give it a weight if you want, and then click the Save Blocks button.

Some additional notes:

  • You can add several vocabularies to the same block by repeating lines 2 and 3. For example:
    <?php
    $UserMenu = theme_menu_tree(59);
    print $UserMenu;
    $UserMenu = theme_menu_tree(30);
    print $UserMenu;
    ?>

    You can repeat this as many times as necessary.

  • If you disable the taxonomy menu items on the navigation menu, they also disappear from your custom block. To truly separate them, you would have to create a second custom block for your navigation items, then disable the navigation block.
  • Notice that I changed the name of the variable in the second example. That's because it is an arbitrary name. You should use what makes most sense to you.

Please, let me know if this is what you were looking for, and how it works for you.
_________
bob-thompson.com

bwynants’s picture

No dependency to taxonomy menu, same functionality?

vocabulary ID can be found by hovering over edit of vocabulary on categories page.

<?php
// Note: Change the '2' below to whatever vocabulary ID you're using
$terms = taxonomy_get_tree(2);
  print "<div class=\"item-list\"><ul>";
  foreach($terms as $term) {
    $looptid = $term->tid;
    $loopname = $term->name;
      print "<li><a href=\"taxonomy/term/$looptid\">$loopname</a></li>";
  }
  print "</ul></div>";
?>
BobT-1’s picture

That's pretty slick. A couple comments.

It wouldn't work on my site, at first, because I need "?q=" before taxonomy in the URL, like so:

<?php
$terms = taxonomy_get_tree(1); // my forums are tax 1
   print "<div class=\"item-list\"><ul>;
   foreach($terms as $term) {
      $looptid = $term->tid;
      $loopname = $term->name;
         print "<li><a href=\"?q=taxonomy/term/$looptid\">$loopname</a></li>";
   }
   print "</ul></div>;
?>

Second comment is - this prints a flat list of all terms in a vocab, giving no indication that one is a child of another. So the answer to, "same functionality?" is, "close, but not quite." Still, this may suffice for Adriana's purposes and is more elegant than my solution, given its independence of taxonomy_menu. In fact, I disabled both taxonomy_menu and menu. It has no dependency on either.

Thanks!
_________
bob-thompson.com

mikolaskova’s picture

It works fine, thank you... but I need both: no taxonomy in the main navigation and hierarchy in the new navigation block...But it's fine for the moment and I will try to add the difference between child menu-entries and parent menu-entries later...