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

XF 1.1 What is wrong with this template condition?

Discussion in 'Troubleshooting and Problems' started by RoldanLT, Feb 19, 2013.

  1. RoldanLT

    RoldanLT Well-Known Member

    Code:
    <xen:if is="{$postId} == 2 AND !{$visitor.user_id} AND !in_array({$forum.node_id}, array(23,26,74,76,77,79,89,93,94,95,106,108,159,160,161,162,198))">
     
    CONTENT HERE
     
    </xen:if>
     
     
    <xen:if is="{$postId} == 3 AND !{$visitor.user_id} AND !in_array({$forum.node_id}, array(23,26,74,76,77,79,89,93,94,95,106,159,160,161,162))">
     
    CONTENT HERE
     
    </xen:if>


    It doesn't work or display.
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    Firstly, what template are you using this in?

    Next, be methodical with it...

    Break it down and test it piece by piece...

    So first try:

    Code:
    <xen:if is="{$postId} == 2">
    CONTENT
    </xen:if>
    If that works... try the next bit...

    Code:
    <xen:if is="{$postId} == 2 AND !{$visitor.user_id}">
    CONTENT
    </xen:if>
    And keep going until you identify where it has gone wrong. Most of those conditions look correct so hopefully doing it like I've suggested above will single out the one that's wrong.
     
    RoldanLT likes this.
  3. RoldanLT

    RoldanLT Well-Known Member

    Template: ad_message_below
     
  4. RoldanLT

    RoldanLT Well-Known Member

    I tested this code:

    <xen:if is="{$postId} == 2">
    TEST CONTENT
    </xen:if>

    It didn' t work :(
     
  5. Chris D

    Chris D XenForo Developer Staff Member

    For that template, it wouldn't work.

    ad_templates are for advert code - they don't have any parameters available to them.

    So basically the ad_message_below template hasn't got a clue what $postId means.
     
  6. RoldanLT

    RoldanLT Well-Known Member

    Instead of using ad_message_below
    Better I use "message" template?
     
  7. Chris D

    Chris D XenForo Developer Staff Member

    Yeah that should work.
     
    Evina likes this.
  8. RoldanLT

    RoldanLT Well-Known Member

    Thanks !
    I will try.
     
  9. RoldanLT

    RoldanLT Well-Known Member

    Still didn't work, I inserted it inside "message" template:

    Code:
    <article>
                    <blockquote class="messageText ugc baseHtml{xen:if $message.isIgnored, ' ignored'}">
                        <xen:include template="ad_message_body" />
     
    <xen:if is="{$postId} == 2">
    TEST CONTENT
    </xen:if>
     
                        {xen:raw $message.messageHtml}
                    </blockquote>
                </article>
     
  10. Chris D

    Chris D XenForo Developer Staff Member

    Probably because $postId doesn't exist eiter.

    I think you mean $message.post_id
     
    RoldanLT likes this.
  11. RoldanLT

    RoldanLT Well-Known Member

    How can I use that as xen/if conditionals?
     
  12. Chris D

    Chris D XenForo Developer Staff Member

    The same way...

    <xen:if is="{$message.post_id} == 2">
    TEST CONTENT
    </xen:if>
     
  13. RoldanLT

    RoldanLT Well-Known Member

    Still, not displaying/didn't work.
     
  14. Chris D

    Chris D XenForo Developer Staff Member

    Are you trying to show content in the post with an ID of 2 (that is, out of all of the many posts on your forum, the single post with an ID of 2) or are you trying to show content in the post in every single thread that is the 2nd post in that thread?

    If the latter, I think you want this:

    <xen:if is="{$message.position} == 2">
    TEST CONTENT
    </xen:if>

    But, actually, the position starts at 0 so the second post would be 1
     
  15. RoldanLT

    RoldanLT Well-Known Member

    Still not working.
     
  16. Chris D

    Chris D XenForo Developer Staff Member

    What are you trying to do?

    I'm only guessing based on the information you provide.
     
  17. RoldanLT

    RoldanLT Well-Known Member

  18. RoldanLT

    RoldanLT Well-Known Member

    I just manually coded that ads placement with xf conditional.
     
  19. Chris D

    Chris D XenForo Developer Staff Member

    This works for me...

    <xen:if is="{$message.position} == 2">
    TEST CONTENT
    </xen:if>

    [​IMG]

    I don't know why it isn't working for you.
     
    RoldanLT likes this.
  20. RoldanLT

    RoldanLT Well-Known Member

    On what template did you add it?
    How is the placement?
     

Share This Page