PDA

View Full Version : Please help urgently


SilverBoy
10-24-2015, 12:58 AM
Hi dears

I used this code to show author avatar in both article page and article preview page (section page).

require_once(DIR . '/includes/functions_user.php');
$avatarurl = fetch_avatar_url($this->content->getUserId());
if ($avatarurl[0]) {
$avatarurl = $avatarurl[0];
}
/* render template and register variables */
vB_Template::preRegister('vbcms_content_article_pa ge',array('avatarurl' => $avatarurl));
vB_Template::preRegister('vbcms_content_article_pr eview',array('avatarurl' => $avatarurl));

I use the hook vbcms_article_populate-end and it works great in article page, but it show the same avatar for all authors in section page, any suggestion to make it works right in section page?

this is the code I use in the templates.
<img class="cms_article_preview_image" src="{vb:raw avatarurl}" alt="{vb:raw $authorname}">

Dead Eddie
10-24-2015, 08:55 AM
Haven't tested this lately, but it worked last time I did it:

require_once(DIR . '/includes/functions_user.php');
$avatarurl = fetch_avatar_url($view->authorid, true);
if ($avatarurl[0]) {
$avatarurl = $avatarurl[0];
}
/* render template and register variables */

$view->avatarurl = $avatarurl;

SilverBoy
10-24-2015, 11:46 AM
Thank you for your help Eddie.

But your code looks like the same as I used, btw what is the hook that I must insert this code using it?

--------------- Added 1445694815 at 1445694815 ---------------

Thank you Eddie, It works great :)