Adding User Avatars to lastpost Node

J2A

Member
Just having some difficulty tweaking this template and understanding how the User avatar system works

Code:
<xen:avatar user="$forum.lastPost"  img="true" />

I've noticed the size property is used here, but all the sizes are unsuitable for what i require and also with this code it links to the correct profile but the (just shows the default avatar) actual avatar of the user does not display?

Any suggestions how to get this work correctly? Heres what i want it to look like: http://dribbble.com/shots/166859-Forum

Any help would be appreciated! (This should be in the questions section)
 
The last post data is lost because the avatar is pushing it down. You'll have to float the avatar to the left and probably extend the container by about 20 pixels to the left.

The CSS syntax can be added to the EXTRA.css template.
 
Very nice implementation Luke. You could even go a step further and wrap it inside a link to the post or the profile.

Thank you James! You know its funny, for the last hour I've been debating just that. I'm thinking its a bit more relevant to link to the post. I feel it adds to the "real time" feel of things. Seems like many users ignore the "last post" text alone and instead are only looking for a change in the icon. The photo will encourage more clicking directly to the post.

What would I have to throw into it to have it link to the last post?
 
Very nice implementation Luke. You could even go a step further and wrap it inside a link to the post or the profile.
It's actually very simple. Just go into your EXTRA.css template and add:

Code:
.nodeLastPost img

{

add desired CSS here :)

}

You can really have any look you desire.

I actually already implemented it on my working site http://www.slruser.com/

Enjoy
Very nice.
Can you post your CSS in the
.nodeLastPost img
 
...and after all that I realise you're after the forum last post. I'll get onto that.
------------------------------------------------------------------------------------------------------
For forum last post info:
Open up node_forum_level_2
Find:
Code:
<xen:if is="{$forum.lastPost.date}">
{xen:phrase latest}: <a href="{xen:link posts, $forum.lastPost}" title="{$forum.lastPost.title}">{xen:helper wordTrim, $forum.lastPost.title, 30}</a>
<span class="lastThreadMeta"><xen:username user="$forum.lastPost" />, <xen:datetime time="$forum.lastPost.date" class="muted" /></span>
<xen:else />
Replace:
Code:
<xen:if is="{$forum.lastPost.date}">
<xen:set var="$avatarGroup">{xen:if '{$forum.lastPost.user_id} < 1000', '0', '{xen:helper snippet, $forum.lastPost.user_id, 1}'}</xen:set>
<img src="data/avatars/s/{$avatarGroup}/{$forum.lastPost.user_id}.jpg?{$forum.lastPost.date}" alt="{$forum.lastPost.username}" />
{xen:phrase latest}: <a href="{xen:link posts, $forum.lastPost}" title="{$forum.lastPost.title}">{xen:helper wordTrim, $forum.lastPost.title, 30}</a>
<span class="lastThreadMeta"><xen:username user="$forum.lastPost" />, <xen:datetime time="$forum.lastPost.date" class="muted" /></span>
<xen:else />
James,
I just copy and paste this into to edit my template and realize the code is for userid< 1000 and I have 10K+ users with id >20K so this will not scale very well.

I have to revert the template and look for better way to do this than to have too many xen:if in the template.
 
James,
I just copy and paste this into to edit my template and realize the code is for userid< 1000 and I have 10K+ users with id >20K so this will not scale very well.

I have to revert the template and look for better way to do this than to have too many xen:if in the template.

You'd have to use a couple of conditionals to see which group the user ID belongs to.
If user ID < 1000, group 0
If user ID 1000-1999, group 1
If user ID 2000-2999, group 2
etc

Seems like this would be workable. Probably not very efficient, but workable yes?
 
I just copy and paste this into to edit my template and realize the code is for userid< 1000 and I have 10K+ users with id >20K so this will not scale very well.
I had to realize it up to 20K. When saving the code in one part i got an Syntax-error. Now i had to split it up in too parts. It works, but it's a ...hm ...let's say: an uncomfortable, big code.
 
James,
I just copy and paste this into to edit my template and realize the code is for userid< 1000 and I have 10K+ users with id >20K so this will not scale very well.

I have to revert the template and look for better way to do this than to have too many xen:if in the template.
The code I provided will work for any ID up to 9999. You'd have to create another conditional for 10,000 to 100,000 etc.
 
I had to realize it up to 20K. When saving the code in one part i got an Syntax-error. Now i had to split it up in too parts. It works, but it's a ...hm ...let's say: an uncomfortable, big code.
Should only require another conditional:
{xen:if '{$forum.lastPost.user_id} > 9999', '{xen:helper snippet, $forum.lastPost.user_id, 2}'}

This should work up to user ID 99,999
 
Top Bottom