Hi guys. I am new to PW so I need some help. I can't figure out something basic here I think. I have the following code in the template file:
namespace ProcessWire;
$content = $page->body;
$posts = $page->children("limit=10");
if(!empty($posts)):
foreach($posts as $post):
$content .= renderBlogItem($post);
endforeach;
else:
$content .= "<h3>No articles found</h3>";
endif;
$pagination = $posts->renderPager();
$content .= $pagination;
And the following code in renderBlogItem function:
function renderBlogItem($post){
return '<div class="item">
<h2> <a href="'.$post->url.'">'.$post->title.'</a></h2>
<div>'. substr(strip_tags($post->body), 0, 375) .'...</div>
<p><a href="'.$post->url.'">Read full story ></a></p>
<span>'.$post->createdUser.'</span>
</div>
';
}
The issue is that fields are outputed differently from their actual values, for example for createdUser I have printed a number, for createdDate I have timestamp instead of the full date I have when I print the $post variable. What am I missing here ?
Thanks.