Help with displaying Page Owner in blog entry
Permalink
I've seen this requested before - but I haven't found a working solution yet...
I want to display the "Owner" (set through properties/attributes) as the "Author" of a blog entry. I see that the author is obtained here (in blog_entry.php):
This echos the original creator of the page. If the editor "edits" the blog post, they become the "Author".
I want to have a site editor enter or edit a blog post for another user and set the "Owner" attribute (so that the appropriate user is shown as the "Author"). Is there a way to do display the "Owner" attribute rather than the creator or last editor of the page? I assume I'll have to do something similar in the page list (for the blog index to use the "Owner")?
Shawn
I want to display the "Owner" (set through properties/attributes) as the "Author" of a blog entry. I see that the author is obtained here (in blog_entry.php):
This echos the original creator of the page. If the editor "edits" the blog post, they become the "Author".
I want to have a site editor enter or edit a blog post for another user and set the "Owner" attribute (so that the appropriate user is shown as the "Author"). Is there a way to do display the "Owner" attribute rather than the creator or last editor of the page? I assume I'll have to do something similar in the page list (for the blog index to use the "Owner")?
Shawn
Unfortunately you're going to need to do this in a few steps, this should work.
$userID = $c->getCollectionUserID(); $u = User::getByUserID($userID); $userName = $u->getUserName();
Thanks for the reply. I tried:
but it doesn't output anything. At least it's not throwing an error, so I might be closer! I'm not confident/competent enough to be sure my syntax is correct.
<div class="pageSection"> <h1><?php echo $c->getCollectionName(); ?></h1> <p class="meta"><?php echo t('Posted by')?> <?php $userID = $c->getCollectionUserID(); $u = User::getByUserID($userID); $userName = $u->getUserName(); echo $username; ?> on <?php echo $c->getCollectionDatePublic('F j, Y'); ?></p> </div>
but it doesn't output anything. At least it's not throwing an error, so I might be closer! I'm not confident/competent enough to be sure my syntax is correct.
This all looks good except that your $userName variable doesn't match case in both places. If you match the case in both places it should work.
Yep. Syntax got me! This works just as I intended. I applied it similarly to the page list and that works too.
Thanks so much.
Thanks so much.
instead of
does get me closer. But that gives the user ID (number)... I need to get the name now.