First of all, you're setting "publisher" and "publishDate" and in your Tpl chunk, you're displaying "poster" and "published," which don't exist.
Second, createdby will give you a user ID, which is probably not what you want to display.
Try something like this (untested):
<?php
$output = array();
$resource = $modx->getObject('modResource',$id);
if ($resource) {
$publisher = $resource->getOne('CreatedBy');
} else {
return 'Resource not found';
}
if ($publisher) {
$output['publisher'] = $publisher->get('username');
} else {
$output['publisher'] = 'anonymous';
}
$output['publishDate'] = $resource->get('publishedon'));
$show = $resource->getTVValue('showInfo');
if($show){
return $modx->getChunk('Meta.tpl',$output);
} else {
return "";
}
Then, in the Tpl chunk:
<p class="meta">
Posted by [[+publisher]] on [[+published:strtotime:date=`%m-%d-%Y`]]
</p>
BTW, if this is for the current resource, you can skip the getObject() call and replace it with this:
<?php
$resource =& $modx->resource;
In that case, you also won't need the "if" test for $resource.
[ed. note: BobRay last edited this post 14 years, 11 months ago.]