I want to show the backend users userimage and name on the frontend page. Is there any placeholders or any other tags I can use to get this?
Thanks.
I think, thererfor I am! But what I am, and why...?
I know this snippet can show managers _online_ by usernames:
http://modxcms.com/forums/index.php/topic,31712.msg193147.html#msg193147
Maybe modify showmember snippet to do this would be the way to go... That snippet enables all the placeholders.
But how to is something I dont know in my head...
Although this is a very simple example, it could at least set a start point for you:
Create a snippet and call it (uncached I think is best) [!YourSnippetName!] in your document where you want the name and image to appear.
<?php
/* Author_name_photo
*/
$output ="";
$tbl = $modx->dbConfig['table_prefix'];
$authorID = isset($authorid) ? $authorid : $modx->documentObject['createdby'];
if($authorID != ""){
$sql = "SELECT fullname,photo
FROM ".$tbl."user_attributes
WHERE ".$tbl."user_attributes.internalKey = ".$authorID;
$rs = $this->dbQuery($sql);
$limit = $this->recordCount($rs);
if($limit > 0 && $limit < 2) {
$user = $this->fetchRow($rs);
$modx->setPlaceholder('author_fullname', $user['fullname']); // [+author_fullname+]
if($user['photo'] != ""){
$modx->setPlaceholder('author_photo', '<img src="'.$user['photo'].'" alt="'.$user['fullname'].'">'); // [+author_photo+]
}else{
$modx->setPlaceholder('author_photo', 'no photo available');
}
// print out the info or use it in a chunk after the snippet is called
$output .="created by: [+author_fullname+] <br>";
$output .="[+author_photo+]";
}
}
return $output;
?>
hope this helps
Work perfect! Thanks.
I think, thererfor I am! But what I am, and why...?