Форуми / Cotonti / Extensions / Last poster avatar plugin question

Twiebie
#1 31.08.2012 01:33

I've build a little plugin a while ago (with help from Luke), that shows the avatar from the last poster in the forums sections and topics list.

It works quite well, but when a section contains a sub forum it will display the avatar from the user in the sub forum, instead of the avatar from a more recent topic/post in the normal (parent) section.

The code:

if ($y && $z) {
	$category = $z;
} else if ($y) {
	$category = $y;
} else if ($x) {
	$category = $x;
}

$sqllasttopic = $db->query("SELECT * FROM $db_forum_topics WHERE ft_cat=".$db->quote($category)." ORDER BY ft_updated DESC LIMIT 1");
$rowlasttopic = $sqllasttopic->fetch();

$sqllastposter = $db->query("SELECT * FROM $db_users WHERE user_id=".$db->quote($rowlasttopic['ft_lastposterid'])."");
$rowlastposter = $sqllastposter->fetch();

$t->assign(array(
	'POSTER_AVATAR_SECTIONS' => $rowlastposter['user_avatar'],
	'POSTER_AVATAR_SECTIONS_NAME' => $rowlastposter['user_name'],
));

I've tried some different combinations, but haven't managed to sort it out.

Can anyone else maybe shine a light on this?