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

Conditional Statements

Guide and tutorial for conditional statements using XenForo syntax

Tags:
  1. Brogan

    Brogan XenForo Moderator Staff Member

    Brogan submitted a new resource:

    Conditional Statements - Guide and tutorial for conditional statements using XenForo syntax

    Read more about this resource...
     
  2. DRE

    DRE Well-Known Member

    Thank you for posting this as a resource. I hunt down your FAQ thread just to jump to the conditional statements tutorial at least once a month cause something always comes up to where I'll need it. I even bookmarked that thread at one point. Posting this as a resource will make this a lot easier to find, thank you.
     
  3. Matthew Hawley

    Matthew Hawley Well-Known Member

    I want to only show something to a user if he has posts in a thread. How do i do this?
     
  4. cclaerhout

    cclaerhout Well-Known Member

    What is the meaning of the percentage in this conditional:
    Code:
    <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == x AND !{$message.conversation_id}">
    This content will show after post x on every page in a thread
    </xen:if>
    Is it the modulus operator or something else ?
     
    Adam Howard likes this.
  5. SchmitzIT

    SchmitzIT Well-Known Member

    Looks like mod to me.
     
  6. Brogan

    Brogan XenForo Moderator Staff Member

    The use of % in this instance ensures that the conditional applies to every page of the thread.

    If it was just <xen:if is="{$post.position} == 0 AND !{$message.conversation_id}"> then it would only show on the first page.
     
    Mirovinger, radu81 and cclaerhout like this.
  7. Allan

    Allan Well-Known Member

    Conditionals for RM, exist ?
     
  8. Brogan

    Brogan XenForo Moderator Staff Member

    What are you trying to do?
     
  9. Allan

    Allan Well-Known Member

    Hide BB code "Code, html, and php", but only into RM and if it's possible only in certain categories
     
  10. Brogan

    Brogan XenForo Moderator Staff Member

    Allan likes this.
  11. Allan

    Allan Well-Known Member

    I'll tested with this conditional: <xen:if is="{$category.resource_category_id} == x">
     
  12. Robbie Poe

    Robbie Poe New Member

    Thanks for this resource, @Brogan. If I only wanted to show a button to a user on their own personal details page (it's going to be an edit button), how do I condition everyone out except for the user?
     
  13. Brogan

    Brogan XenForo Moderator Staff Member

    That page is only available to the logged in user anyway.
     
  14. Robbie Poe

    Robbie Poe New Member

    Right, but if User X is browsing the site, I would only want an "Edit Profile" button showing up on User X's profile pageā€”not User Y's page.
     
  15. Brogan

    Brogan XenForo Moderator Staff Member

  16. Robbie Poe

    Robbie Poe New Member

    Ahh, right. Sorry. It's the individual member pages I'm talking about. The ones that have the Profile Posts, Recent Activity, Infomation, etc. tabs on them.
     
  17. Brogan

    Brogan XenForo Moderator Staff Member

    Brogan updated Conditional Statements with a new update entry:

    Making the category ID available for use in the ad_ templates

    Read the rest of this update entry...
     
    RoldanLT likes this.
  18. RoldanLT

    RoldanLT Well-Known Member

    Thanks for this Brogan (y)
     
  19. Bram

    Bram Well-Known Member

    I would like to show content under the sticky post but only on the first page of a forum.

    Anybody know how do I prevent the content from showing on page 2, 3 etc.?
     
  20. Brogan

    Brogan XenForo Moderator Staff Member

    How many sticky threads do you have?

    Most forums usually only have a few so the ad_thread_list_below_stickies will work for that.
     

Share This Page