Here's How to Display Page Author Information in Page Templates

Permalink 3 users found helpful
There are a lot of posts out there that display various ways of displaying the page author/owner on a blog post or other page_type template.

Here's the method I'm using, and it works great.

Feel free to add to this if you have any thoughts on it.

This bit of code assumes the following:

- You've installed the Page Selector Attribute from the Marketplace
- You've added a few custom User Attributes to display more than just the user name
- This method bypasses the User Profiles that concrete5 creates by default, because I find them to be rather clunky and hard to customize. So I use the Page Select attribute and attach it to a user to provide a link to that person's profile, which is just a normal page in the sitemap under the Authors Section

<div class="posted-by">
<?php 
$ih = Loader::helper('image'); //load the Image Helper to crop our profile picture
$p = Page::getCurrentPage(); //get the current page to work with it's information
$ownerID = $p->getCollectionUserID(); //gets the User ID of the Page Owner
$ui = UserInfo::getByID($ownerID); //with the User ID, load a UserInfo object
$ownerName = $ui->getUserName(); //get the username of the page owner
$fullName = $ui->getAttribute('full_name'); //Custom Tex attribute called 'full_name'
$jobTitle = $ui->getAttribute('job_title'); //Custom Text attribute called 'job_title'
$bioLink = $ui->getAttribute('bio_page'); //Custom Page Select Attribute for the Bio Page URL
$bioPage = Page::getByID($bioLink); //Using the ID that Page Select Attribute returns, get the collection associatd with it
$url = $bioPage->getCollectionPath(); //Get the URL to the sitemap page for the User Bio ID
$profilePic = $bioPage->getAttribute('profile_pic'); //Custom Image Attribute for the Bio Page called 'profile_pic'
if(isset($profilePic)) {
   $profileThumb = $ih->getThumbnail($profilePic, 90, 90, true); //check to see that the profile pic is set. If so, crop to 90x90


Here is all of this in action:
http://knsiradio.com/sports/stories/big-flies-back-diamonds-strong-...

leinteractive
 
drennapete replied on at Permalink Reply
drennapete
You are awesome, I was battling with this for hours.

Have to say that I really like the KNSI site, very clean.
webporter replied on at Permalink Reply
webporter
Thanks for sharing this!

Do I have to do something special to get the Page Selector Attribute to show in the User Attributes select list? I've installed the package, but it doesn't show up as an Attribute type that I can choose from :(

- Mal