By joachim on
I'm using hook_link_alter to add a node link to blog nodes.
It's a link to another type of node that's picked with a nodereference CCK field.
That all works fine.
But the link to the other node is showing up in my node.tpl's $terms variable, as if it were a taxonomy term.
So on Garland theme, the link to the other node shows in the usual row of node links (Person's blog, add comment, read more, etc etc), but also in the list of taxonomy terms (at the bottom right in Garland, at the top of the node with the date and author in Zen).
This is my code in the hook:
if ($node->type == 'blog') {
// build up some variables based on the field value here
$links['joachim_programlink'] = Array(
'title' => $program_title,
'href' => $program_url,
'attributes' => Array(
'title' => 'Read about the related radio show',
)
);
}
What am I doing wrong?
Comments
Any ideas?
I'm getting this too. Did you ever figure out how to resolve this? Or does anyone else know what's going on?
Thanks!
-c.
I decided to live with it as
I decided to live with it as for my site it actually makes sense to have the radio show link appear as a taxo.
Should file a bug report for it though, as it's not supposed to be happening as far as I can see -- and if it *is*, the docs for the hook need to say so.
Agreed
We switched over to hook_link and that seems to remove the duplication. I'm not sure that's the best way to go, but at least it works. I thought hook_link was for modules that provide their own content types, which we're sort of doing, but not really since they're CCK content types.
The documentation for hook_link_alter needs to deal with this, if it is a feature. If it's a bug, we need to report it. I'd like to have more confirmation about what's going on here first though because I'm not sure which it is. Also, the documentation needs to explain the $links array. What does each element consist of? Another array? What are the keys? How should they be filled in? What do they mean? I shouldn't have to find code examples elsewhere for how to go about this.
Reported the issue here
Reported the issue here
Yup, that worked for me
Yup, that worked for me too.
But... now I'm wondering if there's a way to have the link show only in the Taxonomy terms. In other words, create a fake taxonomy term.
Given the fact that creating
Given the fact that creating a fake taxonomy term is an ugly thing to do, you could try an ugly hack:
Use hook_link to add a link to the links section. Then use hook_link_alter to check if that link exists in the $links array. If it does, remove it. If it doesn't, you're looking at the taxonomy links, so you can add a link there. Told you it was ugly...
I don't think it's a
I don't think it's a heinously ugly thing to do...
I'm using CCK noderef to mark blog posts as related to another node type. Seems reasonable enough to show the relatedness in the same place as taxonomy: 'list of links to stuff related to this node'.
There is the very nifty http://drupal.org/project/taxonomy_redirect which I've used for other stuff (making a taxo term go to a view), but that requires the taxonomy term to actually exist in the first place.
And I know of the NAT module, but auto-creating a term for each node is needless duplication.
I'll try your hack!
Then again, I could do it at the theming rather than the module level, and shove the link in with the other taxo links...
Got it figured out with
Got it figured out with theming!
http://drupal.org/node/272828