so i've got a community site, for a town, one main vocabulary - vid 5 - with about 11 terms under it - trying to throw a link to a page in the main navigation that shows 'all items for that vocabulary' with the most recent one first AND also not display them 'grouped' by term but rather just show most recent at top, show term in tags line etc (that's working - but it also appears as a tag again above grouped teasers by term right now because they're being grouped by term AND then showing most recent first within these little groups)

the code is below - and i'm not a php guy so not sure what to edit or pull out - i'm just trying to get it to show all items (teasers) from the whole vocab (all terms) and show most recent first and not group them as it's doing now...and also not show the term with count of items in the term above each group (i've got a block doing that on the side for navigation and drilling down by term)

any ideas??? for those interested - this was from the handbook on drupal, and while it was old, it does in fact work just fine in d6.1 if you want to try it out for one of your own vocabularies...but it's just not showing things the right way for me!

  $vid = 5;         // <---- put correct vocabulary ID here
  $terms = taxonomy_get_tree($vid);
  echo '<ul>';

  foreach ($terms as $term) {
    $count = taxonomy_term_count_nodes($term->tid);
    echo "\n<li>". l($term->name,'taxonomy/term/'.$term->tid)." (".$count.") - ".$term->description .'</li>';

    // Note: the number of nodes selected is controlled by 'feed_default_items' from the RSS publishing settings page.

    $result = taxonomy_select_nodes(array($term->tid), 'or', 0, FALSE, 'n.sticky DESC, n.created DESC');
    echo "\n<ul>";
    while ($node = db_fetch_object($result)) {
      echo "\n<li>". node_view(node_load($node->nid), TRUE, FALSE, FALSE) .'</li>';
    }
    echo '</ul>';
   }
  echo '<ul>';

Comments

zeta ζ’s picture

Bear in mind that it’s nearly 5am!...

  $vid = 5;         // <---- put correct vocabulary ID here
  $terms = taxonomy_get_tree($vid);
  $tids = array();
 
  foreach ($terms as $term) {
    $tids[] = $term->tid;
  }
  // Note: the number of nodes selected is controlled by 'feed_default_items' from the RSS publishing settings page.

  $result = taxonomy_select_nodes($tids, 'or', 0, FALSE, 'n.sticky DESC, n.created DESC');
  echo "\n<ul>";
  while ($node = db_fetch_object($result)) {
    echo "\n<li>". node_view(node_load($node->nid), TRUE, FALSE, FALSE) .'</li>';
  }
  echo '</ul>';

___________________
It’s in the detaιls…

zilla’s picture

worked like a charm! thank you so much. i owe you one. - any idea how to get user profile pictures out of the teasers in that same code so they only show in nodes for that vocab? or is that a different workflow?

now what's really strange - but not directly related - i'm looking at teasers, one vocab multiple terms - each node is presented with a dropdown of terms (required) and optional 'freetagging'

..so say term 1 is sports and term 2 is business - and tags are also thrown in - when looking at teaser or full node, in one term the free tags are to the left of the term and in the other they're to the right - very strange!!! is this a display bug?

for example:

teaser 1
Term1 freetag [e.g. Sports soccer cleats bloodyshins]

teaser 2
freetag Term2 [e.g. stocks funding Business]

...and does this within the node as well...just odd...trying to get term from vocab on left, free tags to the right of it...i need some sleep too ;)

zeta ζ’s picture

Maybe you need to put your freetagging into a separate vocab. I think entering a new freetag simply adds it to the list available, so they’re not separate.

Order looks like reverse alphabetical to me! Not surprising if you have only one vocab.
___________________
It’s in the detaιls…

zilla’s picture

i see this too - the nodes are forced to select from dropdown list (taxonomy) but also optional freetagging (e.g. 'schools' from a dropdown and then 'name of school' could be a freetag)

thanks again.