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

Template Conditionals Question

Discussion in 'XenForo Questions and Support' started by fattony69, Mar 2, 2011.

  1. fattony69

    fattony69 Well-Known Member

    Hey,

    I have been trying to work with template conditionals for my advertisements and I have been facing an issue with them.

    I am trying to make it so that the advertisement doesn't load in one forum and only certain usergroups can see it. Here is what I have (that doesn't work).

    Code:
    <xen:if is="!in_array({$forum.node_id}, array(39))">
    <xen:if is="{$visitor.user_group_id} == 1 OR {$visitor.user_group_id} == 2 OR {$visitor.user_group_id} == 3 OR {$visitor.user_group_id} == 4">
    Enter Code Here
    </xen:if>
    </xen:if>
    What do I have to change?
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    I did it the other way and excluded adverts for certain usergroups using AND.

    Code:
    <xen:if is="!{xen:helper ismemberof, $visitor, 3} AND !{xen:helper ismemberof, $visitor, 4} AND !{xen:helper ismemberof, $visitor, 5} AND !{xen:helper ismemberof, $visitor, 6} AND !{xen:helper ismemberof, $visitor, 7}">
    <xen:include template="cta_adsense_banner_narrow" />
    </xen:if>
    That will block adverts to any member of groups 3, 4, 5, 6 and 7.


    For the node I use this code:
    Code:
    <xen:if is="{$quickNavSelected} != 'node-55'">
    <xen:include template="cta_adsense_banner_narrow" />
    </xen:if>
    That will stop adverts from being shown in node 55 completely.


    Altogether it looks like this:
    Code:
    <xen:if is="{$quickNavSelected} != 'node-55'">
    <xen:if is="!{xen:helper ismemberof, $visitor, 3} AND !{xen:helper ismemberof, $visitor, 4} AND !{xen:helper ismemberof, $visitor, 5} AND !{xen:helper ismemberof, $visitor, 6} AND !{xen:helper ismemberof, $visitor, 7}">
    <xen:include template="cta_adsense_banner_narrow" />
    </xen:if>
    </xen:if>
     
    The8thLegion likes this.
  3. Floris

    Floris Guest

    that will only check if the user is in the primary usergroup. This .. it won't matter, if the user browsing the page is in usergroup with id 5 , primary, or secondary.

    <xen:if is="{xen:helper ismemberof, $visitor, 5}">


    [edit: sneak brogan with inline edit]
     
  4. fattony69

    fattony69 Well-Known Member

    Code:
    <xen:if is="{$quickNavSelected} != 'node-39'">
    <xen:if is="!{xen:helper ismemberof, $visitor, 5}">
    enter code here
    </xen:if>
    </xen:if>
    Edit...This doesn't show up when using Testing Permissions, but when logged in, it works. ODD.
     

Share This Page