PDA

View Full Version : Display Avatars on Related Posts



seekyt
05-15-2012, 06:03 PM
I am having a syntax problem that I hope one of you can help me with.

I have found a way to display the avatars of the post authors in the "Related Posts" part of an article.

By opening up content/plugins/related_posts/related_posts.php and navigating to ~line 250

I add this:


$user = $user = new UserBase();
$user->getUserBasic($h, $h->post->author);


if ($h->isActive('avatar')) {
$h->setAvatar($user->id, 10);
echo
$output .= $h->wrapAvatar();
}

Right before this line:


$output .= "<div class=\"related_posts_link " . $indent . "\">";



Voila - the avatars are displayed. However, I get this major problem:

1624

As you can see, the related posts get repeated - first 0 posts, then 1, then 2, then 3, then 4, and then 5 (I set the max to 5 in the plugin settings). Any idea what I did wrong?

frytec
05-16-2012, 12:30 AM
you dont need this "echo"

i think you also dont need that user declaration.

and you should use it after the indent and use linkAvatar instead of wrapAvatar for better looking.

try that simple way above , and check if it works.

add this:

if ($h->isActive('avatar')) {
$h->setAvatar($h->post->author, 10);
$output .= $h->linkAvatar();
}

AFTER

$output .= "<div class=\"related_posts_link " . $indent . "\">";


;)

seekyt
05-16-2012, 01:20 AM
WOW I wish I could pick your brain. I think I spent close to three hours messing things up. Thanks a million!