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

Change template for usergroup

JordanH

Well-known member
#1
I'm looking to add a template edit for users who upgraded on my forum.

Basically, I cant use the basic
"<xen:if is="{xen:helper ismemberof, $user, 9}">"

set up because it is going to be inside a class. And we all know you can't put HTML in side HTML already.

So this is what I'm trying to get.

This is my current <li>:
<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}">

I'm trying to add inside the CLASS tag "premium". I have went in the faq's searched around the forums, and nothing came up.

Really, this feature was suggested to me, so I liked it and willing to implement it. However, I can't seem to get it to work.

If any of you have seen how Digital Point's forum works you would know that premium options have a different colour in their thread listing then normal users. That's about what I'm trying to achieve here.
 

0xym0r0n

Well-known member
#2
class="discussionListItem <xen:if is="in_array({$thread.secondary_group_ids}, array(3))">premium</xen:if> {$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}">

insert the usergroup ids for the premium usergroup where the #3 is at. Separate with commas if more than one (3, 4, 7)

in extra.css add
.discussionListItem.premium {background-color: #fff !important;
color: #ff0000 !important;}


My result is every other admin post will have a white background
Screen Shot 2013-04-28 at 12.05.52 AM.png
 

JordanH

Well-known member
#3
class="discussionListItem <xen:if is="in_array({$thread.secondary_group_ids}, array(3))">premium</xen:if> {$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}">

insert the usergroup ids for the premium usergroup where the #3 is at. Separate with commas if more than one (3, 4, 7)

in extra.css add
.discussionListItem.premium {background-color: #fff !important;
color: #ff0000 !important;}


My result is every other admin post will have a white background
View attachment 45297
Theres no way that could work :/

Edit:

Ya I tested that. It don't work. :(

Thats like trying to put html inside a class tag.

<span class="<html>" Just won't work will it?
 

0xym0r0n

Well-known member
#4
No, that's placing a conditional inside html. I've been doing it for weeks lol
I'm not quite sure why it didn't work for you but that's why i took a screen shot. It worked for me.

Did you change the usergroup ID # correctly?
If your feel like going long way around then do an xen:if and xen:else *search for conditionals or this*
if usergroup is x the show code option 1 with premium class
else every other group show original code option with out premium class
That would not make your place ANY 'html within html' but it would be more code.
 

0xym0r0n

Well-known member
#7
Ya, I made sure i changed the user group:
http://prntscr.com/12hsuo

I just have no idea :/
WELL long way around.

Find
<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}">​

Replace with
<xen:if is="in_array({$thread.secondary_group_ids}, array(9))">premium</xen:if>​
<li id="thread-{$thread.thread_id}" class="discussionListItem premium {$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}">​
<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'} " data-author="{$thread.username}">​
</xen:if>​
Extra.css
.discussionListItem.premium {}

NINJA'd by Jake :)
That link should work too.
 

JordanH

Well-known member
#8
The one you told me to replace with the long way wont even save. It gives a syntax error.

@jake I understand that it should work, but I did exactly has he said (even tried your way in the link you provided) and it just wont. I even showed a SS what I did.
 

0xym0r0n

Well-known member
#9
Whoops I sent you wrong code "premium</xen:if>" was not supposed to be in there lmfao

Replace with
<xen:if is="in_array({$thread.secondary_group_ids}, array(9))">​
<li id="thread-{$thread.thread_id}" class="discussionListItem premium {$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}">​
<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'} " data-author="{$thread.username}">​
</xen:if>​
 

JordanH

Well-known member
#10
Whoops I sent you wrong code "premium</xen:if>" was not supposed to be in there lmfao

Replace with
<xen:if is="in_array({$thread.secondary_group_ids}, array(9))">​
<li id="thread-{$thread.thread_id}" class="discussionListItem premium {$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}">​
<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'} " data-author="{$thread.username}">​
</xen:if>​
Sadly that don't even work either. I just have NO idea why this is not working. Its driving me crazy. I will add all of that, and even go to the live site, view the source and see if the premium is even in the class tag where it is suppose to be, Its not. :/

Maybe I'm editing the wrong template.
 

tyteen4a03

Well-known member
#11
It actually should be
Code:
 {xen:if 'in_array($thread.secondary_group_ids, array(3)', 'premium'}
Remember, everything that is a tag also works in curly braces form (might require some tweaking here and there, but they're pretty much interchangeable except control structures maybe)
 

0xym0r0n

Well-known member
#12
AND are you apply it to the correct style? If you're apply it to a style that you're not currently using, then it will not apply...
 

JordanH

Well-known member
#13
It actually should be
Code:
 {xen:if 'in_array($thread.secondary_group_ids, array(3)', 'premium'}
Remember, everything that is a tag also works in curly braces form (might require some tweaking here and there, but they're pretty much interchangeable except control structures maybe)
That gives a syntax error as well.

AND are you apply it to the correct style? If you're apply it to a style that you're not currently using, then it will not apply...
It dont even matter if I apply it to the right style or not, because if you go to the live forum, and the user is premium, their thread should still have that "premium" in their class if there is a style for premium or not. Which it dont.
 

tyteen4a03

Well-known member
#14
That gives a syntax error as well.


It dont even matter if I apply it to the right style or not, because if you go to the live forum, and the user is premium, their thread should still have that "premium" in their class if there is a style for premium or not. Which it dont.
You might have to insert an extra , '' at the end, I'm not sure if the else argument must be there.
 

0xym0r0n

Well-known member
#15
Paste the whole code here of the template you are editing.
I see pixelExit did your site have you consulted them? Perhaps there is a slight chance of a template conflict?*i doubt it*
but all examples work on my offline and live site so it is somethibg on your end.

The style does matter because if you are doing it in the master and not the child it will not show for the child. Somone correct me im wrong. Which is a likely reason for you applying code and nothing showing for premium users in the css
 

JordanH

Well-known member
#16
This is the entire template without the premium edit:

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'}" 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>
 
    <div class="listBlock main">
 
        <div class="titleText">
            <h3 class="title">
                <xen:if is="{$thread.canInlineMod}"><input type="checkbox" name="threads[]" value="{$thread.thread_id}" class="InlineModCheck" id="inlineModCheck-thread-{$thread.thread_id}" data-target="#thread-{$thread.thread_id}" title="{xen:phrase select_thread}: '{$thread.title}'" /></xen:if>
                <xen:if is="{$showSubscribeOptions}"><input type="checkbox" name="thread_ids[]" value="{$thread.thread_id}" /></xen:if>
                <xen:if is="{$thread.prefix_id}">
                    <xen:if is="{$linkPrefix}">
                        <a href="{xen:link forums, $forum, 'prefix_id={$thread.prefix_id}'}" class="prefixLink"
                            title="{xen:phrase show_only_threads_prefixed_by_x, 'prefix={xen:helper threadPrefix, $thread, plain, ""}'}">{xen:helper threadPrefix, $thread, html, ''}</a>
                    <xen:else />
                        {xen:helper threadPrefix, $thread}
                    </xen:if>
                </xen:if>
                <a href="{xen:link "threads{xen:if '{$thread.isNew} AND {$thread.haveReadData}', '/unread'}", $thread}"
                    title="{xen:if '{$thread.isNew} AND {$thread.haveReadData}', {xen:phrase go_to_first_unread_message}}"
                    class="{xen:if $thread.hasPreview, PreviewTooltip}"
                    data-previewUrl="{xen:if $thread.hasPreview, {xen:link threads/preview, $thread}}">{xen:helper wrap, $thread.title, 50}</a>
                <xen:if is="{$thread.isNew}"><a href="{xen:link threads/unread, $thread}" class="unreadLink" title="{xen:phrase go_to_first_unread_message}"></a></xen:if>
            </h3>
 
            <xen:if hascontent="true">
                <div class="iconKey">
                <xen:contentcheck>
                    <xen:hook name="thread_list_item_icon_key" params="{xen:array 'thread={$thread}'}">
                    <xen:if is="{$thread.isModerated}"><span class="moderated" title="{xen:phrase moderated}">{xen:phrase moderated}</span></xen:if>
                    <xen:if is="!{$thread.discussion_open}"><span class="locked" title="{xen:phrase locked}">{xen:phrase locked}</span></xen:if>
                    <xen:if is="{$thread.sticky}"><span class="sticky" title="{xen:phrase sticky}">{xen:phrase sticky}</span></xen:if>
                    <xen:if is="{$thread.isRedirect}"><span class="redirect" title="{xen:phrase redirect}">{xen:phrase redirect}</span></xen:if>
                    </xen:hook>
                </xen:contentcheck>
                </div>
            </xen:if>
 
            <div class="secondRow">
                <div class="posterDate muted">
                    <xen:username user="$thread" title="{xen:phrase thread_starter}" />,
                    <a{xen:if {$visitor.user_id}, ' href="{xen:link threads, $thread}"'} class="faint"><xen:datetime time="$thread.post_date" title="{xen:if {$visitor.user_id}, '{xen:phrase go_to_first_message_in_thread}'}" /></a><xen:if is="{$showForumLink}">,
                    <a href="{xen:link forums, $thread.forum}" class="forumLink">{$thread.forum.title}</a></xen:if>
 
                    <xen:if is="{$showLastPageNumbers} AND {$thread.lastPageNumbers}">
                        <span class="itemPageNav">
                            <span>...</span>
                            <xen:foreach loop="$thread.lastPageNumbers" value="$pageNumber">
                                <a href="{xen:link threads, $thread, 'page={$pageNumber}'}">{$pageNumber}</a>
                            </xen:foreach>
                        </span>
                    </xen:if>
                </div>
 
                <div class="controls faint">
                    <xen:if is="{$thread.canEditThread}"><a href="javascript:" data-href="{xen:link 'threads/list-item-edit', $thread}" class="EditControl JsOnly">{xen:phrase edit}</a></xen:if>
                    <xen:if is="{$showSubscribeOptions} AND {$thread.email_subscribe}">{xen:phrase email}</xen:if>
                </div>
            </div>
        </div>
    </div>
 
    <div class="listBlock stats pairsJustified" title="{xen:phrase members_who_liked_first_message}: {xen:if $thread.isRedirect, '&ndash;', {xen:number $thread.first_post_likes}}">
        <dl class="major"><dt>{xen:phrase replies}:</dt> <dd>{xen:if $thread.isRedirect, '&ndash;', {xen:number $thread.reply_count}}</dd></dl>
        <dl class="minor"><dt>{xen:phrase views}:</dt> <dd>{xen:if $thread.isRedirect, '&ndash;', {xen:number $thread.view_count}}</dd></dl>
    </div>
 
    <div class="listBlock lastPost">
        <xen:if is="{$thread.isRedirect}">
            <div class="lastPostInfo">{xen:phrase n_a}</div>
        <xen:else />
            <dl class="lastPostInfo">
                <dt><xen:if is="{xen:helper isIgnored, $thread.last_post_user_id}">{xen:phrase ignored_member}<xen:else /><xen:username user="$thread.lastPostInfo" /></xen:if></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>
        </xen:if>
    </div>
 
</li>
 
</xen:if>
If you think you are able to make the edit and send it back please let me know.