How can I get access to the uid of the author in node.tpl?

lomoboy - September 9, 2006 - 20:46

So I need to output link to the user's blog near the submitted filed instead of $link array.

How can I get access to the uid?

$node->uid holds the owner id of the node

nevets - September 10, 2006 - 00:25

title says it all

thanks!

lomoboy - September 10, 2006 - 17:30

maybe you know how to delete user's blog link from $link?

One way to do it

nevets - September 10, 2006 - 18:20

The following is a variation of the information found at http://drupal.org/node/44708.
First add the following to you themes template.php file (if there is not one you will need to add it)

<?php
function phptemplate_links($links = array(), $delimiter = ' | ') {
 
/**
* catches the theme_links function and calls back a link.tpl.php file to determine the layout
*/
 
return _phptemplate_callback('links', array('links' => $links, 'delimiter' => $delimiter));
}
?>

(Leave of the <?php and ?> if adding to an existing template.php file.)

The create links.tpl.php in you theme directory and add

<?php
/**
* to change the delimiter, just modify the $delimiter value
* Add in other fixed links to the link array by adding something like
* $links[] = l('link text', 'link path');
*
*/

$delimiter = "|";
// Display the left cap of the 'button bar'
print ""; // put whatever you want here - using nothing in this case

$display_links = array();

foreach (
$links as $lnk ) {
   
$key = strstr($lnk, 'blog');  // does a search in for blog in the link
    // Keep if not a blog link
   
if ($key === FALSE) {
     
$display_links[] = $lnk;
    }  
}
if (
count($display_links) > 0 ) {
    print
implode($display_links, $delimiter);
}

// Display the right cap of the 'button bar'
print ""; // put whatever you want here
?>

Note this will remove ANY link that has blog somewhere in it.

thanks, nevets!

lomoboy - September 10, 2006 - 18:55

Very useful for me.

 
 

Drupal is a registered trademark of Dries Buytaert.