Hey there.
Im trying to change the display of the $links in node.tpl.php
Im using a prettified dynamic button system to enhance the look of the links.
Ive almost got a working example here:
http://drupal.brandform.net/
or a subdomain....
http://blog.mixdv.com/
you can see that the middle button is not displayed correctly in the $links array.
the "top" link is just for display purposes to show the right side of the connected buttons functioning properly.

my problem is that I need to wrap a <span> tag around the middle link, AND grab the last link in the array and wrap a <span class="last-child"> around that link.

I would like to always show at least two buttons (a left and a right) if possible:
something like "continue reading" and "add comment"

i found this on another post but it would only solve part of my problem. i see here that i can put the "add comment" php right in the node.tpl.php
can i do that for each link?

<?php
global $user;
if (
$user->uid) {
  print (
'<a href = "/comment/reply/'. print $node->nid. '">add comment</a>');
  }
else {
  print (
'Please log in to post a comment');
}
?>

I figure theres a couple of ways to go about this.
anyone know how to accomplish this?

Comments

nevets’s picture

Nice look to your links.

There is a theme function (theme_links) that provides the look for the links. By adding the file template.php (or adding the function below to the existing one) and defining links.tpl.php you can achieve what you want.
Contents of template.php (or addition to)

<?php
/**
 * Catch the theme_item_list function, and redirect through the template api
 */
function phptemplate_links($links = array(), $delimiter = ' | ') {
 
// Pass to phptemplate, including translating the parameters to an associative array. The element names are the names that the variables
  // will be assigned within your template.
 
return _phptemplate_callback('links', array('links' => $links, 'delimiter' => $delimiter));
}
?>

Then create a links.tpl.php. The following example should work as a guideline. Instead of graphics it just uses characters

<?php
// If you want you could add other fiixed links to the links array
//  something like
//  $links[] = l('link text', 'link path');
//

// Display the left cap of the 'button bar'

print "[";
$link_count = count($links);
$current = 1;
foreach (
$links as $lnk ) {
       
// Print the link
   
print $lnk;
       
// Only print the delimiter if not the last link
   
if ( $current < $link_count ) {
        print
$delimiter;
    }
   
$current++;
}
// Display the right cap of the 'button bar'
print "]";
?>
trickfoxx’s picture

Youre the bomb.
Its almost working the way im wanting!

I still need to put the <span class="last-child"> before the last link so it applies the right side image to the button.

how do I do that?

Also the "read more" link is not displayed on each node teaser.
is there way to check and see if its in the array and if not, add it?
Or possibly I could just check to see if there is only 1 link in the array as sometimes exists and if so, add the "read more" link with the <span class="last-child"> after????

divrom’s picture

This is almost exactly what I was looking for, but I'd like to take it further.

If there is a link to comments, I'd like to have a little speech-bubble symbol, next to the author's name/link I want to add a link for that, and I'd like to add a printer symbol for the printer-friendly version.

I was thinking of adding a class to each of the links and then putting the image as a background, via css.

------
Felix web Creations | Think Happy!
Forward Therapy : Solution-focused Hypnotherapy Northampton