Complete and flexible blogging platform for ProcessWire

Post Author

MarkupBlog module ships with five widgets that you can use to enhance user experience in your Blog. One of this is the Author Widget. To output this Widget, we use the postAuthor() widget. 

<?php
/**
* Render a Blog post's author widget.
*
* @access public
* @return $out string
*
*/
public function postAuthor()

The method takes no arguments and is very simple to use as illustrated below. The method should be called on a Template File used by a Blog Post page. If you want the Author Widget to appear before the Post, call this method before renderPosts(). If you want it at the bottom, call it after the Post, just before you output the Post comments. Since it is a stand alone widget, really, you can call it anywhere you wish within that Template File.

<?php
//first we call MarkupBlog ONLY IF WE HAVEN'T ALREADY
$blog = $modules->get("MarkupBlog");

//out a Blog Post's Author's Full Names, Photo Thumb and Bio
echo $blog->postAuthor();

postAuthor() HTML Output

The following is the HTML markup produced by the method postAuthor(). Note that it will display the Author's name only in case that user's full names have not yet been saved in their user profile (in their title field). If available, it also displays the Author's photo thumb and their biography. 

<div id="post-author" class="clearfix">
 <!-- if no title was provided, the user's ProcessWire name would be used instead -->
 <a title="Homer Simpson">
  <!-- this thumb is automatically created from the uploaded author photo in the user template -->
  <img class="author-photo" src="/pwtests/site/assets/files/41/homer-original.100x0.jpg" alt="" width="100" height="150">
 </a>
 <!-- post author title/name as explained above -->
 <h4 class="post-author-name">Homer Simpson<small> Author</small></h4>

 <!-- this is output from the author's bio input in the field blog_body found in the 'user template-->
 <p><strong>Homer Jay Simpson</strong>&nbsp;is a cartoon character who appears in the animated television series The Simpsons as the patriarch of the eponymous family. He is voiced by Dan Castellaneta and first appeared on television, along with the rest of his family, in The Tracey Ullman Show short "Good Night" on April 19, 1987. Homer was created and designed by cartoonist Matt Groening while he was waiting in the lobby of James L. Brooks' office. Groening had been called to pitch a series of shorts based on his comic strip Life in Hell but instead decided to create a new set of characters. He named the character after his father, Homer Groening. After appearing for three seasons on The Tracey Ullman Show, the Simpson family got their own series on Fox that debuted December 17, 1989.</p>
</div>

postAuthor() CSS IDs and Classes

This is the CSS output by postAuthor(). Use this to style the Author Widget.

div#post-author {}
div.clearfix {} /*using .clearfix:after, you can use this to clear a floated author's photo*/
img.author-photo {}
h4.post-author-name {}

Summary

MarkupBlog comes with five widgets we can use to augment our Blog. One of these is the Author Widget. We use the method postAuthor() to display an Author Widget on a Blog Post page. The method takes no arguments.