Hi Everyone,
I'm a struggling newbie and hope you can help me ...

What I am trying to accomplish ...
The navigation menu contains a top-level entry called "Clubs".
Under "Clubs" there are entries for "Bridge Club", "Chess Club", etc.
When the user clicks on "Bridge Club", they go to webpage for the Bridge Club.
The webpage for the Bridge Club contains a "welcome" tab, a "contact us" tab, etc.
And similarly for all the other clubs, i.e. the webpages for all the clubs have this same basic format.

What I have succeeded in doing so far ...
a) I created a vocabulary called "Clubs" with the terms "Bridge", "Chess", etc.
b) Using the Views module, I created a new view called "welcome".
I checked "provide page view";
I set the url to "clubs/$arg/welcome";
Under menu, I checked "provide menu", "provide menu as tab", and "make default menu tab".
Under arguments, I added "taxonomy term name", and set to %1.
I then cloned this view to create a second view called "contact us", and unchecked the "make default menu tab" box.
c) When I go to http://mysite/clubs/Chess I see a page labeled "Chess" with a "welcome" tab and a "contact us" tab. So that's working fine.

Question #1:
How do I create a top-level entry "Clubs" in the navigation menu, with child-entries for the various terms in that vocabulary ("Bridge" , "Chess", etc) so that when someone clicks on "Chess" they go to http://mysite/clubs/Chess.

Question #2:
Is it possible to suppress some of the terms from showing up in the navbar? (The reason is that I have one catchall term "all" which is not a club and which I therefore do not want to show up in the nav bar.)

Thanks so much for your help!
Mindy

Comments

venkat-rk’s picture

Question #1:
How do I create a top-level entry "Clubs" in the navigation menu, with child-entries for the various terms in that vocabulary ("Bridge" , "Chess", etc) so that when someone clicks on "Chess" they go to http://mysite/clubs/Chess.

Simply use drupal's menu module to build your own menu? Since you have implemented the other menu in views as tabs, just go to the menu building section in the admin area, click on 'add new menu' and follow the steps. For the links to the taxonomy terms, you can click on 'add menu item', put the path to the taxonomy term (taxonomy/term/1 etc or the aliased name of the term) and you should be done. Since you are manually building the menu, you can easily leave out the term 'all'.

All you have to do after this is to enable your menu block at admin/block. While doing so, you can even specify if your menu should be visible only on particular pages.

----
Previously user Ramdak.

kobnim’s picture

Thanks to everyone who posted ... glad I asked!

NancyDru’s picture

The taxonomy menu module might be good for you - and you might be able to get rid of the views.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

MacRonin’s picture

Thanks for pointing this one out. Some how I missed it, and I know just the place I want to use it.

http://drupal.org/project/taxonomy_menu

-------------------
http://www.PrivacyDigest.com/ News from the Privacy Front
http://www.SunflowerChildren.org/ Helping children around the world

Jeff Burnz’s picture

havent used that module much but by memory doesnt it *not* support path alias's, and instead uses it's own URL's like taxonomy_menu/1/7

instead of /clubs/chess

Someting like that I recall? Maybe times have changed?

How would using this module help this user get rid of the views?

NancyDru’s picture

You don't need a View to do taxonomy/term/xxx - that's core stuff. It boggles my mind that so many people code a View to do that.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

Jeff Burnz’s picture

Oh yea, mainly because they dont know I would say, and the way Views presents it to you, you would easily think that views is 'the' way to do it...

felixsmile’s picture

Hi!

Maybe that's a really dumb question, but how would you code it, then? I mean what is 'the' way, or another way you would recommend? You wouldn't want to patch the core, would you?

Thanks,

Felix.

NancyDru’s picture

Find the id of the term (go to Categories >> List terms, hover over the edit link and look in the lower left corner) and then just enter http://www.mysite.com/taxonomy/term/xxx where xxx is the term id. This is fairly "tight" code and it's part of core. The only reason to use Views to show a taxonomy is if you need it sorted in a different order or you need to include header information. But balance your need with the extra overhead.

There's a lot more: http://drupal.org/handbook/modules/taxonomy

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

felixsmile’s picture

OK, thank you :) I thought you meant that one can "personalize" the taxonomy view with a core module.

Obviously, using views is not one of the first option one should think of.

Well then, have a nice day!

Felix

felixsmile’s picture

Taxonomy Context might be a partial solution to your problem: it does use the "standard" paths for taxonomy (unlike taxonomy menu) and shows a list of all the subterms when you click on a parent.

To hide some terms, you could maybe use Taxonomy Access Control and disallow the listing of your "all" term.

Some suggestions, hopefully they'll help you.

Felix

jiangxijay’s picture

This ... taxonomy/term/1 ... delivers a view of all selected nodes types found within that term.

What path do you use to create a menu with the top-level vocabulary, itself?

For this example, I want to add a menu entry for Clubs, not for the terms ...

Vocabulary: Clubs
Terms: Chess, Stamps, Yearbook

NancyDru’s picture

Create a page with php format. Include this code:

<?php
  $vid = 2; /* <---- put correct vocabulary ID here */
  $items = array();
  $terms = taxonomy_get_tree($vid);
  foreach ( $terms as $term ) {
    $count = taxonomy_term_count_nodes($term->tid);
    if ($count) { /* don't show terms with 0 count */
      $items[] = l($term->name,'taxonomy/term/'.$term->tid)." (".$count.") - ".$term->description;
    }
  } /* end foreach */
  print theme('item_list', $items);
?>

Then you can add a menu entry for the page.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

liquidcms’s picture

I think what original poster is looking for is a Top Menu (like in Primary Links) called Clubs - with a Submenu listing each of the Clubs.

Isn't Nancy's page code just giving a page with th items listed - how is that a menu?

So, if i am on the same path here - my app i think generalizes this a bit:

I have a Vocab called "Genres" with rock, pop, rap, etc

And i have a Primary Link manually defined as Videos.

Now, i would like to have a submenu of Videos which is the terms from Genres. And i would like the paths to be something like videos/Rock, Videos/Pop, etc.

- i never want to go to the taxonomy page
- and i dont want to ever see Genres listed in a menu

I tried out tax_menu and it seems close but paths are hard coded - i guess they would need to be token-ized??

Peter Lindstrom
LiquidCMS - Content Management Solution Experts

Prodigy’s picture

Isn't Nancy's page code just giving a page with th items listed - how is that a menu?

The code produces links to all nodes tagged with the vocabulary. The code can go into a block where you can position anywhere you want with regions and/or CSS. It provides navigation, just like a menu.

I have a Vocab called "Genres" with rock, pop, rap, etc

And i have a Primary Link manually defined as Videos.

Now, i would like to have a submenu of Videos which is the terms from Genres. And i would like the paths to be something like videos/Rock, Videos/Pop, etc.

You would be well served with the modules Path-Auto, and Views.

As far as the navigation your after, I'm sure there are some modules in the taxonomy download section that would help you. Off the top of my head, I would just create the Views you're after in Views, and then manually put them in the Menu in admin/menu.

liquidcms’s picture

Hmmm.. perhaps that is the way.. but you mean View (singular) correct? A view of the terms in a list view that get themed to make a block ... and then add block to a region that shows under Primary links and is hidden until Video hover over.

That sounds like it will work.

Still seemed like a menu module would work better - but i guess the Video mennu i created with tax_menu only shows when i am on the video page - but the effect i am looking for is a hover over video pulldown affect.

thanks.

Peter Lindstrom
LiquidCMS - Content Management Solution Experts

yeeloon’s picture

Hi! I know this might not be the right forum to post... But I don't seem to find the topic to this...

I want to create a directory in my front page that shows something like this.

Automobiles
- Honda
- Toyota
- Citroen
- Ford
...(more)

Location
- England
- France
- Germany
- Italy
...(more)

I want to show only the top 4 terms of that particular vocabulary/category. How can I accomplish that?

NancyDru’s picture

<?php
  $vid = 8; /* <---- put correct vocabulary ID here */
  $max = 4; /* <---- how many to show */
  $items = array();
  $save_terms = array();
  $terms = taxonomy_get_tree($vid);
  foreach ($terms as $term) {
    $count = taxonomy_term_count_nodes($term->tid);
    $link = l($term->name,'taxonomy/term/'.$term->tid, array('title' => $count .' items'));
    $save_terms[$link] = $count;
  }
  arsort($save_terms, SORT_NUMERIC);
  $i = 0;
  foreach ($save_terms as $term => $count) {
    $i++;
    if ($i > $max) { break; }
    $items[] = $term;    
  }
  echo theme('item_list', $items);
?>

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

yeeloon’s picture

Thanks nancyw!

It works perfectly...

bsuttis’s picture

How can I edit this snippet to preserve taxonomy hierarchy?

For example, within my vocabulary, I've got a term called 'Games', within it are 'Board', 'Computer', and 'Video'. With the snippet above, it doesn't output the 3 terms below 'Games' in a UL, instead, the terms are just output with the rest of the terms (same UL) as if a multiple hierarchy doesn't exist.

yeeloon’s picture

(Sorry that I do not where to post my question, and it seems this is a difficult thing to tackle)

I've tested with the Taxonomy module with the above solutions... but, now I'm testing it with CCK (by having Location created as a text field type) for user input. Pretty stumped at drupal and php...

But, here's what I've seen somewhere and tested it...

<?php

  $content_type = 'auto';
  // $limit = array();

  global $base_url;
  $result1 = db_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = '$content_type' AND n.status = 1 ORDER BY n.created DESC));
  while ($node = db_fetch_object($result1)) {
     $node_loaded = node_load($node->nid);

     $output .= '<a href="' . $base_url . '/?q=node/' . $node->nid . '">' . $node_loaded->title . '</a>';
     $output .= '<br />';
     $output .= '<a href="' . $base_url . '/?q=node/' . $node->nid . '">' . $node_loaded->field_location[0][value] . '</a>';
     $output .= '<br />';
  }
print $output;
?>

The output was something like this:

Location:
BMW X5
- New York
Audi A5
- New York
Ford Focus
- Los Angeles
Ford Focus
- Chicago

So, my question is how can I achieve something like this (similar to the Taxonomy code)

Location:
New York (2)
Chicago (1)
Los Angeles (1)

Anybody come across this before... using CCK queries?

rmahon’s picture

Try this

$sql = 'Select `category`,count(*)'
. ' From clubs'
. ' Group by `category`;';

Ron Mahon
http://The-villages-info-center.com
Yet another Drupal Site