Closed (fixed)
Project:
Drupal core
Version:
6.6
Component:
taxonomy.module
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
12 Jan 2012 at 12:00 UTC
Updated:
7 Feb 2012 at 14:10 UTC
Hi,
I am using the below stated code to display the terms associated with the page.Is there any way to show it in ascendng and descending order alphabetically.
/**
* Prints an unordered list of the terms (as links) that are
* associated to the currently displayed node.
if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
$node = node_load(arg(1));
$vid = 2;
$terms = taxonomy_node_get_terms_by_vocabulary($node, $vid);
if ($terms) {
print '<ul>';
foreach ($terms as $term) {
print '<li>'.l($term->name, 'taxonomy/term/'.$term->tid).'</li>';
}
print '</ul>';
}
}
**/
Current Result:
Mango
Apple
Orange
Bananna
Required Result:
Apple
Bannana
Mango
Orange
Comments
Comment #1
kars-t commentedHi
please use the Views module to get this running. Makes more sense to get some experience with Views in any case!
Comment #2
donkasok commentedThankyou for your valid input.Hope i will get it done via views
Comment #3
donkasok commentedHi i have tried to play with views.But didnt gave any result i desired. Can you help me to achive this.
Comment #4
kars-t commentedHi donkasok
basically you create a view about a node. Use a contextual filter with the current node id that is in the current URL. A node URL is always "node/123" for views not the alias that you can see in the browser. So you can use this easily with Views.
Than select the taxonomy field. This already should be an unordered list.
Please take a looka this:
http://dev.nodeone.se/node/701
Views is the best contrib module there is. You can do many amazing things with it. So it is a good invest to learn Views!