Question
war_boar wrote:
how to have a block of links to all terms which match taxonomy like Reviews: Anime Or Reviews: Movies without doing it manually
it should be titled, Reviews and underneath all blogs or stories which matched.
Answer
You might want to use the Taxonomy Menu module.
You will need to create a new Block of type=php
. You will then want to paste in the code below, and customize the 'Physicians' subject and the $tax array. $tax the list of tids that you are interested in. The third element, named 'operator', can be and or or. So in your case, assuming the term ID for movies is '3' and the term ID admin/taxonomy/edit/term/3 for Anime is '6' admin/taxonomy/edit/term/6, you want:
// paste this code into a custom block of type=php
// customize the $tax array and the $subject as needed
$tax = array(3, 6);
$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);
A Block that returns the first 5 terms for a taxonomy
$taxo_id = 3;
$sql = "SELECT node.title, node.nid FROM node INNER JOIN term_node ON node.nid = term_node.nid WHERE term_node.tid = $taxo_id LIMIT 5";
$output .= "<ul>";
$result = db_query($sql);
while ($anode = db_fetch_object($result)) {
$output .= "<li>".l($anode->title, "node/$anode->nid")."</li>";
}
$output .= "</ul>";
return $output;
Comments
Snippets in code section
This seems a bit redundant, unless the PHP snippet section is now obsolete.
This can be found at: http://drupal.org/node/23220
Seems redundant.. but still needed?
I'm using taxonomy (with a hierarchical system) to manage my content but the display is not what I was expecting.
(D7)
If I click on any tag, I get other pieces of content matching that tag = not a problem.
If I click on a parent tag, I expect to see all content items matching the child tags as well. Is this a bug if it's not working?
My example:
Taxonomy = regions
Regions = Australia & Melbourne.
Clicking Australia should show me first the content items that match Au and then the ones that match Melb, Syd, Perth etc.
Do I have to use a custom snippet/block as suggested to get this behaviour? Thought it would be in the box. :(
I like this code.
It was very helpful.
I add a code to make a link such as 'read more'. I hope it is also helpful to others.
watchout with D7
get this error when adding the snippet to a page ..
(so no block ..)
tried the tax menus module,
but i guess i need the custom page ;)
http://drupal.org/update/modules/6/7#dbtng
here a working snippet:
D7 Snippets
Thanks ysturk,
Solved a few issues for me as we wait for Views and Chaos Tools to be ready for D7.
Do you know of any more snippets for 7?
Especially to give your snippet above more versatility. eg: teaser length, number of items... Or could you point in the right direction.
thanks
allanx
sneppehzz
ähm - i posted some regarding taxonomy in the forums,
http://drupal.org/node/1067332
http://drupal.org/node/1067350
be more specific, maybe i can provide you something ;)
regarding your questions:
edit: BTW - i got views and ctools installed and they work quite franky ..
Thanks
Thank u i am looking for same
good job,but how can I change
good job,but how can I change display style?eg:title style...
Drupal 7: PHP filter is disabled by default
If you don't have the 'php code' option for your block type, you need to enable the PHP filter module. Here's more information: http://drupal.org/node/1046700
Create new book or menu link from a form
I am reading about Drupal 7 features "Book" and "Taxonomy". I am not sure if these features can help me with what I want to accomplish.
What I need is a link in the navigation menu titled "new book". When the user clicks on this link a new page comes up. On the page is a field asking for a "book name" and the page has yes or no 4 questions. Each question relates to a form page. At the bottom of the page is a "create book" button. When the user clicks on the "create book" button the a new link, with the title variable "book name" is created in a menu. Under this link there are 1 to 4 new pages which each contain a series of questions.
I can use the fields feature of Drupal 7 to create the forms to list the questions. However I am not sure how to create the link and sub-links in the menu block and I am not sure how to name the link using the variable "book name".
I am very new to Drupal 7 and a novice php programmer. The biggest thing I am attempting to do is create a new menu item and a series of sub menu items given user information from a form.
Can someone point me to a module or two that might be able to help me accomplish this feature?
Will the "Taxonomy Menu" module help?
Thanks,
Spineless