Posted by sparkells on October 1, 2009 at 5:55pm
3 followers
Jump to:
| Project: | Author Taxonomy |
| Version: | 6.x-1.8 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Hello. I've got Author Taxonomy working perfectly in terms of showing the author's name in an article. However, I'm trying to work out how to add the taxonomy term description for the relevant author - I would like to use the descriptions as author profiles in the articles (most authors will not be site users). Is this possible?
I'm guessing I just need to add a line of code to node.tpl.php but after much searching and testing I've had no luck finding anything that works.
Thanks for any help you can offer.
Comments
#1
I've kept working on this and finally have it working. If it helps anyone else below is my solution. If there is a better way to do this let me know.
I put the following into template.php:
<?php
/**
* Prints an unordered list of the terms (as links) that are associated to the currently displayed node.
* $vid = vocabulary ID number.
*/
function phptemplate_author_profile() {
if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
$node = node_load(arg(1));
$vid = 7;
$terms = taxonomy_node_get_terms_by_vocabulary($node, $vid);
if ($terms) {
foreach ($terms as $term) {
print ($term->description);
}
}
}
}
?>
$vid = 7 refers to the taxonomy vocabulary ID.
I put the following into the appropriate spot in node.tpl.php:
<?php if (phptemplate_author_profile): ?><p><?php print phptemplate_author_profile($node); ?></p>
<?php endif; ?>
#2
It helped a lot! Many thanks.
I choose to put everything in the node.tpl.php, because if i insert the function in the template, the system complains because the function is called twice (!).
#3
See this issue for some relevant info.