include author in blog list block
Permalink Browser Info Environment
I am trying to include the blog page's author as part of the information available in the Pro Blog Page List.
I've tried to shadow the method used in the actual blog page but that code yields nothing (which is better than an error).
The closest I can get is to return the Author's Unique user number (like the superuser is 1 and the second registered user is 2) using this line of code
What we're trying to accomplish can temporarily be seen here:
http://citizen.mcgstrategic.com:8081/index.php/...
I will also need to find a way to link to the author's member page.
Thanks is advance
Ryan Vars
I've tried to shadow the method used in the actual blog page but that code yields nothing (which is better than an error).
The closest I can get is to return the Author's Unique user number (like the superuser is 1 and the second registered user is 2) using this line of code
<?php $ak_a = CollectionAttributeKey::getByHandle('blog_author'); $authorID = $cobj->getCollectionAttributeValue($ak_a); echo $authorID ?>
What we're trying to accomplish can temporarily be seen here:
http://citizen.mcgstrategic.com:8081/index.php/...
I will also need to find a way to link to the author's member page.
Thanks is advance
Ryan Vars
Type: | Discussion |
---|---|
Status: | New |
Brilliant! worked like a charm.
Any thoughts on linking to that author's profile page?
I was using this:
but this is obviously not going to work. I can make the changes to call the right user name but how do I call that user's profile?
Thanks again.
Any thoughts on linking to that author's profile page?
I was using this:
but this is obviously not going to work. I can make the changes to call the right user name but how do I call that user's profile?
Thanks again.
profile/view/$authorID should be the link
12345J,
This seems to want to take you to the profile page of the logged in user. What I mean is that if I'm logged in as admin it takes me to the admin profile page. but if i'm logged in as another user(blogger) the same link takes me blogger's profile page.
could you expand the code a little so I make sure I have the context right?
Thanks
This seems to want to take you to the profile page of the logged in user. What I mean is that if I'm logged in as admin it takes me to the admin profile page. but if i'm logged in as another user(blogger) the same link takes me blogger's profile page.
could you expand the code a little so I make sure I have the context right?
Thanks
12345J,
Thanks for the response but your code is no-go. It does exactly what I said above - it only takes you to the profile page of the user you are signed in as.
Thanks though.
Thanks for the response but your code is no-go. It does exactly what I said above - it only takes you to the profile page of the user you are signed in as.
Thanks though.
really- can you give me the url for the profile of a person that you are not signed in as?
this is what worked:
<a href="<?php echo $this->url('/profile','view', $ui->getUserID())?>">
Has anything changed there in version 5.4.2? Because all I’m getting is:
What I have is:
I have also assigned proper values to the default first and last name attributes for the user. Also, I’ve tried the full_name attribute variant but to no avail. Interestingly the first and last name attribute values aren’t displayed on the user detail page in the admin area. Is this a bug?
On another note, I’d like to display the blog title itself on the blog post listing page. How am I gonna do that?
Fatal error: Call to a member function getUserFirstName() on a non-object in [root path]/blocks/problog_list/view.php on line 36
What I have is:
if (count($cArray) > 0) { ?> <div class="ccm-page-list"> <?php for ($i = 0; $i < count($cArray); $i++ ) { … … $ak_a = CollectionAttributeKey::getByHandle('blog_author'); $authorID = $cobj->getCollectionAttributeValue($ak_a); $ui = UserInfo::getByID($authorID); $name = $ui->getUserFirstName().' '.$ui->getUserLastName();
I have also assigned proper values to the default first and last name attributes for the user. Also, I’ve tried the full_name attribute variant but to no avail. Interestingly the first and last name attribute values aren’t displayed on the user detail page in the admin area. Is this a bug?
On another note, I’d like to display the blog title itself on the blog post listing page. How am I gonna do that?
here's what I used and it worked great! but this is before 5.4.2 and before the newest release of ProBlog
This grabbed the first and last name of the blog author as identified via the dashboard.
We also used this to link to that author's profile page:
Hope that helps!
<?php $ak_a = CollectionAttributeKey::getByHandle('blog_author'); $authorID = $cobj->getCollectionAttributeValue($ak_a); $ui = UserInfo::getByID($authorID); $name = $ui->getUserFirstName().' '.$ui->getUserLastName(); echo $name ?>
This grabbed the first and last name of the blog author as identified via the dashboard.
We also used this to link to that author's profile page:
Hope that helps!
OK, so I’ve found out that the error comes up when a blog post author (or its name(s)) has not been defined. I think I solved it by adding a conditional check:
$ak_a = CollectionAttributeKey::getByHandle('blog_author'); $authorID = $cobj->getCollectionAttributeValue($ak_a); $ui = UserInfo::getByID($authorID); if(isset($ui)) { $name = $ui->getUserFirstName().' '.$ui->getUserLastName(); }
next you need to grab the userInfo object and then pull the name like so:
where the attribute containing the name is called using the user info magic function __call(). so, "$ui->getUser" plus a camel cased name for your user attribute. so if you have a full name attribute instead of first and last with "full_name" for the handle. It would be called in like so: $ui->getUserFullName();
ChadStrat