1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.1 Conditional woes - Display specific user(s) in sidebar

Discussion in 'XenForo Questions and Support' started by Andrej, Jul 3, 2013.

  1. Andrej

    Andrej Well-Known Member

    I have the following code here (which is added to sidebar_online_users) template. What it should do is to display an user with user ID 3 regardless of his status (online/offline).

    Code:
    <!-- block: sidebar_special_users -->
        <div class="section staffOnline avatarList">
            <div class="secondaryContent">
                <h3>Sponsors</h3>
                <ul>
                            <xen:if is="{$user.user_id} == 3">
                                <li>
                                    <xen:avatar user="$user" size="s" img="true" />
                                    <xen:username user="$user" rich="true" />
                                    <div class="userTitle">{xen:helper userTitle, $user}</div>
                                </li>
                            </xen:if>
                </ul>
            </div>
        </div>
    <!-- end block: sidebar_special_users -->
    For some reason, it is not working. I asume it is because I am using wrong conditional, but if I try <xen:if is="{$visitor.user_id} == 3"> it doesn't work either. I suppose there must be something I forgot, so any help is highly appreciated.
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Just hard code it into the template, for example:
    HTML:
    <a href="{xen:link 'members/member.3/'}" class="avatar Av1m" data-avatarhtml="true"><img src="data/avatars/m/0/3.jpg" width="96" height="96" alt="Member" /></a>
    That code is something I use on my site, so just adapt it to suit your requirments.
     
    Andrej likes this.
  3. Andrej

    Andrej Well-Known Member

    Thanks Brogan. I want it to display like the "Staff Online Now" block so I will experiment with the code you have providen. :)
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    Just copy the HTML and CSS classes used.
     
    Andrej likes this.
  5. Andrej

    Andrej Well-Known Member

    That's exactly what I did. :)
    Снимок экрана 2013-07-03 в 14.00.43.png

    Thanks for the help.
     
  6. time

    time Active Member

    how to display username (user ID 3).
     
  7. Jeremy

    Jeremy XenForo Moderator Staff Member

    See:
     
    time likes this.
  8. time

    time Active Member

    @King Kovifor,
    @Brogan code used to display member avatars?
     
    Last edited: Jul 8, 2013
  9. time

    time Active Member

Share This Page