Posted by terryprogetto on April 21, 2008 at 4:21pm
I try to theme the output of taxonomy terms in the node. For default, they themes as a list. But I want to separate them just with comma.
Example: term1, term2 ...
Sorry for my broken English, but I hope for the help. Thanks.
Comments
Somebody, help me please to
Somebody, help me please to solve this problem...
It's difficult to give exact
It's difficult to give exact instructions without knowing the theme you are using. However, in your node.tpl.php file, there is probably a section of code similar to this:
<?php if ($taxonomy): ?><div class="terms"><?php print $terms ?></div>
<?php endif;?>
Replace it with this:
<?php if ($taxonomy) { ?><div class="terms">
<?php
foreach($node->taxonomy as $tid => $taxo)
$taxo_links[] = l($taxo->name,"taxonomy/term/$taxo->tid", array('title' => $taxo->name));
print implode(', ',$taxo_links);
?>
</div>
<?php } >
www.roopletheme.com
Thank you!
Its OK. Thank you very much. I`mdevelopming my own theme. As for my topic`s question - everything is clear. It`s working) As I understood the right end of the code is
<?php}
?>
And if you let me - one more question: what is hook? I read API, saw the list of hooks - but havent understood anything. My php knolewlege is OK, im am a NB only in drupal developming.
For example, we can see in taxonomy.module :
/*** Implementation of hook_link().
*
* This hook is extended with $type = 'taxonomy terms' to allow themes to
* print lists of terms associated with a node. Themes can print taxonomy
* links with:
*
* if (module_exists('taxonomy')) {
* $terms = taxonomy_link('taxonomy terms', $node);
* print theme('links', $terms);
* }
*/
And what can we do with the help of this hook? How can I apply it?
With the regulars... Thanks.
Drupal hooks allow you to
Drupal hooks allow you to 'link in' to various stages of Drupal's processing. If you're just developing a custom theme then you're unlikely to do anything with hooks, since they're largely intended for use in module code. It's a topic that goes well beyond a forum post. But if you're really interested in the subject, I strongly recommend that you pick up a copy of Pro Drupal Development... it is the holy grail of Drupal knowledge.
www.roopletheme.com