By solars on
Hey,
I'm overwriting _phptemplate_links() for some customization.
I have to insert links that depend on the $node->nid but I cannot figure
out how to pass the $node into that function template, so I can
access $node->nid inside my template links.tpl.php.
Please can anyone give me a hint? :(
Thank you,
Christoph
Comments
Are you talking about the set of links below a node?
If yes, you should probably look at hook_link and/or hook_link_alter. hook_link is used to add links to a node and sounds like what you are trying to do. The theme function applies to more than those links and does not necessarily apply to a node.
If I understand you
If I understand you correctly, you could...
1) override your theme_links() function [phphtemplate_links()] and add a $nid = 0 argument (default it to zero so it doesn't screw up other uses of this function). Add code to make it do whatever you need it to depending on nid.
2) from the theme_node function, in the variable creation, call theme_links as:
instead of
Edit/Clarification: This is for overriding the theme_node() function, not for hacking the original. Just want to make sure no one is led astray.
Alright
Both suggestions helped me a lot :)
Have to figure out whats best for my purpose, but thank you very much!
greetings,
Christoph
hm...
okay, I tried that, I overwrote theme_node as mythemename_node() in template.php
and call the links function like this:
theme('links', $node->links, $node->nid)
with the custom links function:
but in links.tpl.php $nid is empty...
whats wrong with that?
Need to modify the callback to include the nid
So you need to change
to
ah right, I forgot that but
ah right, I forgot that
but now $nid is always 0, the default value ..
Nid id third (not second parameter
So
should be
damn ... thanks a lot :)
damn ...
thanks a lot :)
Drupal 6
Hi, I need to do this in Drupal 6. Advice anyone?