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

Highlight Threads made by Premium members?

Discussion in 'Styling and Customization Questions' started by Quiver, May 8, 2013.

  1. Quiver

    Quiver Active Member

    Basically, what I'd like to do is highlight threads made by premium members, so they stand out better in the list of threads in a forum. I only want this feature enabled in certain forums, though. Any ideas how I can implement something like this?
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    You could do this with conditionals and a CSS class.

    Create a new CSS class in EXTRA.css, e.g.:

    Code:
    .premiumMember
    {
    	background-color: yellow;
    }
    Then edit thread_list_item template.

    It has a line that looks like:

    Code:
    <li id="thread-{$thread.thread_id}" class="discussionListItem {$thread.discussion_state}{xen:if '!{$thread.discussion_open}', ' locked'}{xen:if {$thread.sticky}, ' sticky'}{xen:if {$thread.isNew}, ' unread'}{xen:if {$thread.prefix_id}, ' prefix{$thread.prefix_id}'}{xen:if {$thread.isIgnored}, ' ignored'}" data-author="{$thread.username}">
    Add something like this in red:

    Code:
    <li id="thread-{$thread.thread_id}" class="discussionListItem {$thread.discussion_state}{xen:if '!{$thread.discussion_open}', ' locked'}{xen:if {$thread.sticky}, ' sticky'}{xen:if {$thread.isNew}, ' unread'}{xen:if {$thread.prefix_id}, ' prefix{$thread.prefix_id}'}{xen:if {$thread.isIgnored}, ' ignored'}{xen:if '{xen:helper ismemberof, $visitor, 999} AND {$thread.node_id} == 9999', ' premiumMember'}" data-author="{$thread.username}">
    So that code checks if visitor is a member of group 999 (replace this with your premium usergroup ID) and then checks if the thread is in the node with an ID of 9999 (replace this with the desired node ID) and if those two checks are true it adds the class "premiumMember".

    So, with the example as it is above, the thread list item will be highlighted in yellow, like this:

    [​IMG]
     
    Bram, DRE, nguyendattai and 4 others like this.
  3. swatme

    swatme Well-Known Member

    nice chris!

    how about instead of the background color change,
    font color will be changed to red ?
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    What CSS you use is entirely up to you.

    Instead of the background-color: yellow; you would change it to color: red;
     
    swatme likes this.
  5. Quiver

    Quiver Active Member

    This doesn't appear to work.
    What I need it to do is change the premium member's thread colour so it's visible in that new highlighted colour by everyone.
    I applied the code you gave above but, sadly, it had no effect. :(
     
  6. Chris D

    Chris D XenForo Developer Staff Member

    I'm sorry, I did make a mistake.

    This bit of code:
    {xen:helper ismemberof, $visitor, 999}

    Should be:
    {xen:helper ismemberof, $thread, 999}

    Previously the colour was only changing if the current visitor was a member of that group. Now it's checking to see if the thread author is a member of that group.
     
  7. Quiver

    Quiver Active Member

    Sorry, but this still does not work. :(
     
  8. Chris D

    Chris D XenForo Developer Staff Member

    Can you copy and paste here the contents of your thread_list_item template.

    And the code you have added to EXTRA.css.

    It works fine for me.
     
  9. Quiver

    Quiver Active Member

    EXTRA.CSS

    Code:
    .premiumMember
    {
        background-color: yellow;
    }
    THREAD_LIST_ITEM

    Code:
    <xen:require css="discussion_list.css" />
     
    <xen:if is="{$thread.isDeleted}"><xen:include template="thread_list_item_deleted" /><xen:else />
     
    <li id="thread-{$thread.thread_id}" class="discussionListItem {$thread.discussion_state}{xen:if '!{$thread.discussion_open}', ' locked'}{xen:if {$thread.sticky}, ' sticky'}{xen:if {$thread.isNew}, ' unread'}{xen:if {$thread.prefix_id}, ' prefix{$thread.prefix_id}'}{xen:if {$thread.isIgnored}, ' ignored'}{xen:if '{xen:helper ismemberof, $thread, 9} AND {$thread.node_id} == 18', ' premiumMember'}" data-author="{$thread.username}">
     
        <div class="listBlock posterAvatar">
            <span class="avatarContainer">
                <xen:avatar user="$thread" size="s" img="true" />
                <xen:if is="{$thread.user_post_count}"><xen:avatar user="$visitor" size="s" img="true" class="miniMe" title="{xen:phrase you_have_posted_x_messages_in_this_thread, 'count={xen:number $thread.user_post_count}'}" /></xen:if>
            </span>
        </div>
    
    My premium member usergroup is 9, and the forum I'm testing is node ID 18.
    Check here: http://www.twistedpromotion.com/forums/website-monetization.18/
     
  10. Chris D

    Chris D XenForo Developer Staff Member

    Ah ok.

    It is working, look:

    [​IMG]

    See how it has added the "premiumMember" class?

    The problem is, the background colour isn't overriding the existing background colour.

    Change the EXTRA.css code to:

    Code:
    .discussionListItems .premiumMember
    {
    	background-color: yellow;
    }
    You may also want to add the following to EXTRA.css:

    Code:
    .discussionListItems .discussionListItem.premiumMember .posterAvatar,
    .discussionListItems .discussionListItem.premiumMember .stats
    {
    	background-color: yellow;
    }
    
     
    DRE and Quiver like this.
  11. Quiver

    Quiver Active Member

  12. Chris D

    Chris D XenForo Developer Staff Member

  13. Quiver

    Quiver Active Member

    Thanks, works like a charm. :)

    Now, next question. How to configure this for multiple nodes of my choosing?
     
  14. Chris D

    Chris D XenForo Developer Staff Member

    So you currently have this in your code:
    Code:
    AND {$thread.node_id} == 18
    You would want to do something like:

    Code:
    AND in_array({$thread.node_id}, array(18,19,20))
     
    DRE, SportainmentMG and Quiver like this.
  15. Quiver

    Quiver Active Member

    Thanks Chris, I really appreciate the help. :)
     
  16. SportainmentMG

    SportainmentMG Active Member

    Was about to come and ask the same question so thanks to Quiver for having the same idea and to Chris for all of his support - fantastic to see.
     
    Steve F, Chris D and Quiver like this.
  17. OakleyForum

    OakleyForum Active Member

    Does anyone know how to make .discussionlistitem .stats continue or use the same css as .discusionlistitem .premium? Please check the picture. I would like to use a box shadow for the thread, but when I use the same code fot the stats it has the box shadow on the sides. I want it to just be on the top and bottom so it just looks like a continuation of the discussionlistitem style, i.e one highlight, instead of 2.

    So Ideally the highlight, would be on continuous highlight, instead of breaking up when it gets to the stats area.

    Screen Shot 2013-08-08 at 6.13.07 PM.png
     
    BamaStangGuy likes this.
  18. DRE

    DRE Well-Known Member

    This is bigboss status
     
  19. Kenfuzed

    Kenfuzed New Member

    Could the same be done to make all sticky posts highlighted at the top of a forum page?
     
  20. Brogan

    Brogan XenForo Moderator Staff Member

Share This Page