How do I display the author on a published page?
You need a snippet "Author TimeStamp" or similar, please search in Extras section.
This one works for me:
<?php
/* Author_name_photo
*/
$output ="";
$tbl = $modx->dbConfig['table_prefix'];
$authorID = isset($authorid) ? $authorid : $modx->documentObject['createdby'];
if($authorID != ""){
$sql = "SELECT fullname,photo,email
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+]
$modx->setPlaceholder('author_email', $user['email']); // [+author_email+]
if($user['photo'] != ""){
$modx->setPlaceholder('author_photo', '<img class="publisererFoto" src="'.$user['photo'].'" alt="'.$user['fullname'].'" width="45" height="45" />'); // [+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 .="[+author_photo+]";
$output .="<div class=\"publisererNavn\">Av:<br /><a href=\"mailto:[+author_email+]\">[+author_fullname+]</a></div>";
}
}
return $output;
?>
I think, thererfor I am! But what I am, and why...?
Or, for MODx Revolution:
$user = $modx->resource->getOne('CreatedBy');
return $user->get('username');
For the author’s full name:
$user = $modx->resource->getOne('CreatedBy');
$profile = $user->getOne('Profile');
return $profile->get('fullname');
In Revo, you can also do it this way:
[[*createdby:userinfo=`username`]]
Note the capital letters in some (but not all) of the arguments.
Hey, thats great. I’ll look into that BobRay.
I think, thererfor I am! But what I am, and why...?
thanks for all the advice. they seem to work except with NewsPublisher. maybe i’ll have to try revolution on my test site and see if that works.