I got the date/time working. The only thing is changing the Manager User ID to the name.
Like on my website, instead of saying (1), I want it to say (Wilhelm).
EDIT: Also, is there a way to get the st part in something like 31st w/ strftime?
This is where you want the info from after you have established $row[’createdby’]:
$tbl = $modx->dbConfig["dbase"].".".$modx->dbConfig["table_prefix"];
$sql = mysql_query("SELECT * FROM ".$tbl."manager_users WHERE ".$tbl."manager_users.id = ".$row['createdby']."");
Quote from: Soshite at May 30, 2008, 11:14 PM
I got the date/time working. The only thing is changing the Manager User ID to the name.
I found this in he ditto code. I think it will do what you want (perhaps with some modification). You don’t need to change $createdby since it’s just an argument name. Just set $id and call it as
$username = getAuthor($id);
function getAuthor($createdby) {
global $modx;
$user = false;
if ($createdby > 0) {
$user = $modx->getUserInfo($createdby);
} else {
$user = $modx->getWebUserInfo(abs($createdby));
}
if ($user === false) {
// get admin user name
$user = $modx->getUserInfo(1);
}
return ($user['fullname'] != "") ? $user['fullname'] : $user['username'];
}
You could change the last line to:
return $user['username'];
if that’s all you want.
Make this a snippet (name it whatever you want) and add it wherever you want the username to be:
<?php
$tbl = $modx->dbConfig["dbase"].".".$modx->dbConfig["table_prefix"];
$createdbyid = $modx->documentObject['createdby'];
$sql = "SELECT username
FROM ".$tbl."manager_users
WHERE ".$tbl."manager_users.id ='".$createdbyid."'";
$rs = $this->dbQuery($sql);
$limit = $this->recordCount($rs);
if($limit<1) {
$author = "anonymous";
} else {
$user = $this->fetchRow($rs);
$author = $user['username'];
}
return $author;
?>