Here's a patch that adds an option to load term data into the $node object rather than as themed output in $node->content.
This gives a themer more power to place the terms exactly where required in a node template and to format them in any way.
Eg one way is to prepare them to be handed over to theme_links:
$vid = 1; // pick a vocabulary id
foreach ($node->term_display[$vid]['terms'] as $term) {
$my_links['taxonomy_term_'. $term->tid] = array(
'title' => $term->name,
'href' => taxonomy_term_path($term),
'attributes' => array('rel' => 'tag', 'title' => strip_tags($term->description)),
);
}
// pass array to theme_links
$vars['my_vocab'] = theme('links', $my_links);
Comments
Comment #1
nedjoGood idea!
I've assigned you CVS access to the module. Pls go ahead and commit. Pls always commit to HEAD first. Feel free to commit other improvements or fixes, but pls always open issues. Thanks!
Comment #2
nedjoNeeds to be applied first to 6.x and then backported.
Comment #3
joachim commentedHi.
Thanks for giving me CVS access! :)
I don't know that I'll have very much time to give to this module, but I'll help if I can.
I'll get onto this on this week sometime.
Comment #4
joachim commentedHere's the patch for D6.
I've changed the constant definition to:
define('TERM_DISPLAY_LOAD', 'load');
as the value is something stored as a variable rather than seen.
Comment #5
nk_ commentedNedjo, Joachim
I guess you are both very busy ... I am just wondering if/when Joachim's patch will be officially commited ?
And what is going on with those 3 additional styles that I posted patch for it? http://drupal.org/node/367693
Will this be included too?
Don't want to bother just would like to know how this module will look in the next release in order to know what we can expect ... i.e. do I need to maintain my patch for my personal needs or it will be included.
Thanks & Best,
Nenad
Comment #6
joachim commentedHi nk.
I'm hoping to commit the above patch to both branches this week :)
Comment #7
nk_ commentedOk, thanks !
I am looking forward for new version.
Would you like and have some time to test my patch as well?
If definitely not, than I'll make my formatting on theme level for my purposes (this thanks to your patch :).
This is because I don't like to take care of the patch all the time, prefer clean upgrade of module in the future.
On the other hand I think that 3 display styles might be useful for some users who might need something like that and do not have skills
in theme overriding. Let me know your thoughts.
Nenad
Comment #8
joachim commentedA minor change to this patch:
- "load into $node object" with lowercase 'l'. This matches the other labels, though in a future patch I'd like to make them all titlecase.
A bigger change I'd like to make is that it would be more consistent with the contents of $node->taxonomy if the $terms array were keyed by tid rather than just numerically.
This involves changing:
to:
I can make the change just for the LOAD case, or for all three cases -- it doesn't affect the current theme functions as they don't look at the array key at all.
nedjo, what do you think?
Should I make the change just for LOAD in this patch, and then in a new issue change it for the other display types too, or just change it for all now?
Comment #9
niklp commentedAgree with both things.
Comment #10
nk_ commentedKeying with tid makes sense... Title case as well - more drupal-like :)
You didn't mention about 3 styles I submitted patch: 'nodelinks', 'parents', 'plain' ? Maybe Nedjo?
Comment #11
joachim commentednk_ -- about the three extra display styles in your patch.
My feeling is that we shouldn't load this module up with too many options -- keep it simple and slim. I'd go for providing your display styles as sample theme functions, either in a bundled file, or on a documentation page. Probably a docs page would be best, so non-maintainers can update it. We can add instructions and code that shows how to switch on the $vid.
But I have only recently been made a maintainer of this module, so nedjo, this module's main author, may have other ideas :)
Comment #12
nk_ commentedJoachim I am fine whatever you and Nedjo decide regarding this. Ok, let us hear from him too ... but examples in documentation sounds ok as well.
Cheers, Nenad
Comment #13
joachim commentedCommitted these patches to 5 and 6 branches respectively.
Comment #14
Anonymous (not verified) commentedHow can I use it on my node.tpl.php?
Comment #15
joachim commentedSee the documentation page.