By netentropy on
I want to know how to break up the parts of the $links variable in a themed node
for instance
I know print $links will display things like comment, blog link and the service links digg image
how could i split these apart
I know this is wrong but maybe it will give you an idea of what i am trying to do
print $comment_links
print $blog_link
print $service_links
Thanks
Comments
If you have access to $node
If you have access to $node (for example in node.tpl.php) you can access the links as an array using $node->links. Each element of the array is an array.
Print the links array to see
Print the links array to see whats there...
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
So then I can just implode
So then I can just implode the array?
this tells me what array is
this tells me what array is displayed on the page
but i want to know
how can i just recreate the comment portion of the $links variable with all the same functions as comments whether logged in or not
were you able to figure out
were you able to figure out how to do this?
Comments links for all users
I believe you should just be able to change permissions for who can create comments - add the anonymous role.
Subscribing, whats on
Subscribing, whats on $links, greetings, Martijn
i still don't see how to do
i still don't see how to do this
i need to separately call the comments and the read more
not just have it display by calling $links
Hi, So could I
Hi,
So could I put
in page.tpl.php to only get element 1 of the $links array? Is that what this thread says?
I will try this. Now not behind pc where I have access to my source.
Greetings,
Martijn
Any Luck?
Hi,
Did anyone have any luck with this? About to try what Summit/Martijn suggested.
Georg
Hi, No it didn't work for me
Hi, No it didn't work for me somehow..sorry for the late response. Someone else have a suggestion?
I figured it out, if anybody is still interested.
My task was to get rid of the "add comment" option on a taxonomy term page, among some other modifications. To separate the array elements in $link and only display the "Read more" link, in node.tpl.php I replaced
print $links;with this:
print "<a href='/".$node->links["node_read_more"]["href"]."' title='".$node->links["node_read_more"]["attributes"]["title"]."..' >".$node->links["node_read_more"]["title"]."</a>";I couldn't get it to work using index numbers (i.e., $node->links[0][1]). I had to use the string values. That appears to be the trick.
Note the forward slash inserted at the beginning of the link. That's important.
cbroberts26, THANK YOU. this
cbroberts26, THANK YOU. this was not easy, tried a bunch of things and yours finally got me the right solution. I think you wrote your code for Drupal 5? The following worked for me in Drupal 6 (there your code got me 2 links, one empty and one correct):
And this following code shows what variables are available at all:
?>
why does something like
why does something like $links[0] and $links[1] not work?
_
Because the links variable is an associative array with string keys.
As an aside, I find it much easier and more intuitive to alter the links array with theme_links in the template.php file.
ues but even using the string
ues but even using the string key in the brackets does not work
how does this theme function help you seperate them
It allows you to do whatever
It allows you to do whatever you want to the links before they are rendered. For example, to remove the 'user's blog' link you could do:
It all depends on what you want to do.
Thank you WorldFallz , Works
Thank you WorldFallz , Works with me .
Drupal 7 Solution?
Could someone post a drupal 7 solution please?