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?
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
title says it all
thanks!
maybe you know how to delete user's blog link from $link?
One way to do it
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)
<?phpfunction 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
<?phpand?>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!
Very useful for me.