Change

Add User Avatar To Last Post Node

Discussion in 'Suggestions' started by DRE, Dec 22, 2011.

  1. DRE New Member

    One of my favorite template edits that would make a great add-on.

    Got it from here: http://xenforo.com/community/threads/adding-user-avatars-to-lastpost-node.16262/

    Forum Last Post User Avatar example here http://www.the8thlegion.com/board/

    Thread Last Post User Avatar example here http://www.the8thlegion.com/forums/the-public-forum.14/

    thread_list_info
    Find:
    Code:
    <dl class="lastPostInfo">
    <dt><xen:username user="$thread.lastPostInfo" /></dt>
    <dd class="muted"><a{xen:if '{$visitor.user_id}', ' href="{xen:link posts, $thread.lastPostInfo}" title="{xen:phrase go_to_last_message}"'} class="dateTime"><xen:datetime time="$thread.lastPostInfo.post_date" /></a></dd>
    </dl>
    
    Replace:
    Code:
    <dl class="lastPostInfo">
    <xen:set var="$avatarGroup">{xen:if '{$thread.lastPostInfo.user_id} < 1000', '0', '{xen:helper snippet, $thread.lastPostInfo.user_id, 1}'}</xen:set>
    <img src="data/avatars/s/{$avatarGroup}/{$thread.lastPostInfo.user_id}.jpg" alt="{$thread.lastPostInfo.username}" />
    <dt><xen:username user="$thread.lastPostInfo" /></dt>
    <dd class="muted"><a{xen:if '{$visitor.user_id}', ' href="{xen:link posts, $thread.lastPostInfo}" title="{xen:phrase go_to_last_message}"'} class="dateTime"><xen:datetime time="$thread.lastPostInfo.post_date" /></a></dd>
    </dl>
    
    CSS
    Code:
    .lastPostInfo img {
    border: 1px solid #c4c4c4 !important;
    border-radius: 1px !important;
    padding: 1px;
    float: left;
    width: 28px;
    height: 28px;
    margin-right: 1px;
    }
    -----------------------------------------------------------------------------------------------------

    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 />
    
    CSS
    Code:
    .nodeLastPost img {
    border: 1px solid #c4c4c4 !important;
    border-radius: 3px !important;
    padding: 2px;
    float: left;
    width: 23px;
    height: 23px;
    margin-right: 9px;
    }
  2. Vincent Staff Member

    Not everything is replaceable with Template Modifications I'm afraid.
    We can only add things where hooks are available, we can't replace code in templates from an add-on :(
  3. DRE New Member

    Oh okay. At least this thread will come in handy anyway then for peeps wanting to know how to do that template edit.
    Vincent likes this.
  4. Robbo Staff Member

    Actually we can and I often do. It requires me to parse the template into the DOM and find where I want to add the modifications and insert my code. You will find this happens often in my mods so I have made it easier to do it for me with XenPlus. However using DOM every request isn't a good idea. I will need to add some form of caching for it.

Share This Page