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

XF 1.2 Conditional help

Discussion in 'XenForo Questions and Support' started by bladinium, Oct 17, 2013.

  1. bladinium

    bladinium Active Member

    Hello,

    I need help for Ads on second post :

    <xen:if is="{$post.position} == 0 AND {$conversation.first_message_id} == {$message.message_id}">

    I would like the advertising does not appear in the forum: 23 and all sub forums: 23

    Thanks :)
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Use a node ID conditional statement.

    <xen:if is="{$forum.node_id} != 23">
     
  3. bladinium

    bladinium Active Member

    Hello, thanks!

    The problem is that it does not work for sub forum.

    Exemple :

    Forum 1 (Ads ok)
    Forum 2 (Ads ok)
    Forum 23 (No ads)
    Sub 24 (no ads)
    Sub 25 (no ads)
    etc... (no ads)
    Forum 128 (ads ok)

    Thanks for u help
     
  4. Tracy Perry

    Tracy Perry Well-Known Member

    You need to define ALL the nodes you don't want it to display in... probably with an array. Refer to @Brogan's excellent resource at http://xenforo.com/community/resources/conditional-statements.1604/
     
  5. Brogan

    Brogan XenForo Moderator Staff Member

    It should display in all nodes automatically.
    The code I gave was for it not to show in one particular node.

    @bladinium, check you are entering the code correctly.
    Node heirarchy is irrelevant when using the node ID, so it definitely works (tested and confirmed).
     
  6. bladinium

    bladinium Active Member

    @Brogan

    Hello,

    I have the code in template "message"

    PHP:
    <xen:if is="{$post.position} == 0 AND {$conversation.first_message_id} == {$message.message_id}">
        <
    li class="message">

            <
    div class="messageUserInfo">
                <
    div class="messageUserBlock">
                    <
    div class="avatarHolder"><span class="avatar  av2m"><img  src="/1.jpg?1379939746"  width="96px" height="96px"></span></div>

                    <
    h3 class="userText">
                        
    Monsieur
                        
    <em class="userTitle" itemprop="title">Pub</em>
                    </
    h3>

                    <
    span class="arrow"><span></span></span>
                </
    div>
            </
    div>

          <
    div class="messageInfo primaryContent">
                <
    div class="messageContent">
                <
    blockquote class="messageText ugc baseHtml">
    <
    div align="center">         
    <!-- 
    DEBUT DU SCRIPT SLIDER --> 
    <
    xen:if is="{$forum.node_id} != 23">       
        <
    a href="http://www.URL/" onclick="javascript:_paq.push(['trackPageView', '2emepost']);" target="blank"><img src="IMG.gif"  height="170" width="100%" alt="cigarette electronique"/></a>
    </
    xen:if>
    test
    <!-- FIN DU SCRIPT SLIDER -->

                </
    div>
                  </
    blockquote>
                </
    div>
              </
    div>
          </
    li>
    </
    xen:if>
    it appears in the sub forum :'(

    Thanks u for u help
     
  7. Brogan

    Brogan XenForo Moderator Staff Member

    Wrap the whole thing in the node id conditional.

    You currently have it somewhere in the middle.
     
  8. bladinium

    bladinium Active Member

    @Brogan

    Sorry for my English, but if I understand you told me to wrap all the code in the variable, so I made this, but it does not work.


    PHP:
    <xen:if is="{$forum.node_id} != 23">
    <
    xen:if is="{$post.position} == 0 AND {$conversation.first_message_id} == {$message.message_id}">
        <
    li class="message">

            <
    div class="messageUserInfo">
                <
    div class="messageUserBlock">
                    <
    div class="avatarHolder"><span class="avatar  av2m"><img  src="h1.jpg?1379939746"  width="96px" height="96px"></span></div>

                    <
    h3 class="userText">
                        
    Monsieur
                        
    <em class="userTitle" itemprop="title">Pub</em>
                    </
    h3>

                    <
    span class="arrow"><span></span></span>
                </
    div>
            </
    div>

          <
    div class="messageInfo primaryContent">
                <
    div class="messageContent">
                <
    blockquote class="messageText ugc baseHtml">
    <
    div align="center">        
    <!-- 
    DEBUT DU SCRIPT SLIDER -->
        
        <
    a href="" onclick="javascript:_paq.push(['trackPageView', '2emepost']);" target="blank"><img src="s2eme.gif"  height="170" width="100%" alt="cigarette electronique"/></a>

    <!-- 
    FIN DU SCRIPT SLIDER -->

                </
    div>
                  </
    blockquote>
                </
    div>
              </
    div>
          </
    li>
    </
    xen:if>
    </
    xen:if>
     
  9. Tracy Perry

    Tracy Perry Well-Known Member

    Let me get straight on what you want - no ads displayed in forum node #23 and all the associated sub-forums under node 23?
    If so, I am almost positive that you are going to need an array (refer to this post again).

    Something along the lines of an example that @Brogan gives in the resource:
    where (x,y,z) will be the nodes that you do NOT WANT it displayed in.
     
  10. Brogan

    Brogan XenForo Moderator Staff Member

    An array is only required if multiple IDs are going to be entered.
    As it is, he only wants to stop them showing in one node (23) so the simple condition will suffice: <xen:if is="{$forum.node_id} != 23">
     
  11. Tracy Perry

    Tracy Perry Well-Known Member

    @Brogan, I am aware of that but I'm basing the array on his statement of "I would like the advertising does not appear in the forum: 23 and all sub forums: 23" ,which I understood to be inclusive of node 23 and all the nodes he has listed under that one (he gives a more detailed descriptor in post #3 in this topic). In that case (it being more than 1 node) would not an array be required (or multiple statements for each node in the format you provided)?
     
  12. Brogan

    Brogan XenForo Moderator Staff Member

    Hmm, I didn't get that from his posts but perhaps you are right.

    In which case, perhaps the parent conditional will work (along with the node itself)?
    <xen:if is="{$forum.parent_node_id} != x">
     
    Tracy Perry likes this.
  13. Tracy Perry

    Tracy Perry Well-Known Member

    Suggestion... how about adding that nice little snippet into your resource on conditional statements. It's one that I wasn't aware of and probably would be useful to several folks. (y)
     
  14. Brogan

    Brogan XenForo Moderator Staff Member

    It's already there :)

    upload_2013-10-20_11-5-14.png
     
    Tracy Perry likes this.
  15. Tracy Perry

    Tracy Perry Well-Known Member

    As I run off to implement some stuff on my site. I can't believe that I overlooked that.:oops:
     
  16. bladinium

    bladinium Active Member

    I have use aray specified! post resolved :)
     

Share This Page