Show the name of a blog post's author

2 posts by 2 authors in: Forums > CMS Builder
Last Post: July 9, 2015   (RSS)

By Daryl - July 9, 2015

Hi,

If the author is stored in "createdBy.fullname", you should set the 'loadCreatedBy'       => '', to true or just simply remove it from the load records block.

So to display the author's name, it should be:

Posted by <?php echo htmlencode($records['createdBy.fullname']); ?> on <?php echo date("l, F jS, Y g:i a", strtotime($record['date'])) ?>

If you're not sure which variable does the author's name value is stored, can you try to add showme($blogRecords); after the load records block:

// load records from 'blog'
  list($blogRecords, $blogMetaData) = getRecords(array(
    'tableName'   => 'blog',
    'perPage'     => '5',
    'loadUploads' => true,
    'allowSearch' => false,
  ));

showme($blogRecords);

And find the array that contains the author's name. For example:

array[0] =>
         array(
           createdDate => "",
           // ....... more array keys to values
           author => "example",
           // ....... more array keys to values
         );

In the example above, the "author" array key holds the value of the author name. So on your code, it will be:

Posted by <?php echo htmlencode($records['author']); ?> on <?php echo date("l, F jS, Y g:i a", strtotime($record['date'])) ?>

Hope this helps. 

Cheers,

Daryl Maximo
PHP Programmer - interactivetools.com