By enginera on
I found a code that displays all titles from a taxonomy. I want to publish only the first 4 titles. What code I need to put there?
// paste this code into a custom block of type=php
// customize the $tax array and the $subject as needed
$tax = array(2);
$operator = "or";
$result = taxonomy_select_nodes($tax, $operator);
while ($obj = db_fetch_object($result)) {
$node = node_load(array('nid' => $obj->nid));
$items[] = l($node->title, "node/". $node->nid);
}
return theme('item_list', $items);
Comments
Found, but not the newest n titles
This code displayes 5 titles. But I want only the Newest 5.
Any help? How to sort database query?
I have the same question
Does anyone know what the answer is?
UPDATE: it should work in the example to make the line ending "LIMIT 5";" end "ORDER BY node.nid DESC LIMIT 5";" instead.
taxonomy_browser
Have you tried the taxonomy_browser module? It might have the SQL statement or functionality you're looking for...
http://drupal.org/project/taxonomy_browser
Would be great if you could post the solution here if you manage to do it in a php page: PHP page snippets: putting dynamic content into your main page
Dub
DUBLIN DRUPALLER
___________________________________________________
A drupal user by chance and a dubliner by sheer luck.
Using Drupal to help build Artist & Band web communities.
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
how to remove the limit from the code?
sorry for this simple question, but how would you remove the listing's limit, to set it to no limit..
cheers,
b.