If condition with or

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gatsman
    New Member
    • Nov 2008
    • 29
    • 3.6.x

    If condition with or

    I got an if like:
    Code:
      
     <vb:if condition="$channel['nodeid'] != 16">
    <tr><td>Something</td></tr>
    </vb:if>
    but i need it to also check for 20 so it must be something like:
    Code:
      
     if != 16 || 20
    how do i write that
  • BirdOPrey5
    Senior Member
    • Jul 2008
    • 9613
    • 5.6.3

    #2
    Code:
    <vb:if condition="$channel['nodeid'] != 16 || $channel['nodeid'] != 20">
    That's fine notation if you have 2 or even 3 numbers to check, but if you have many more it would get annoying. In that case you can use the in_array function.

    Code:
    <vb:if condition="!in_array($channel['nodeid'], array(16,20,24))">
    You can have as few as 1 element in the array and as many as you can type, so long as each is separated by a comma.

    The ! at the front of the statement means NOT... so if 16, 20, or 24 are NOT in the array, then do whatever it is you are going to do.

    For additional help on custom coding please go to www.vbulletin.org.

    Comment

    • gatsman
      New Member
      • Nov 2008
      • 29
      • 3.6.x

      #3
      The first condition:
      Code:
      <vb:if condition="$channel['nodeid'] != 16 || $channel['nodeid'] != 20">
      wont work but the array will do the trick.
      Thank you

      Comment

      • BirdOPrey5
        Senior Member
        • Jul 2008
        • 9613
        • 5.6.3

        #4
        You may need to use the word OR instead of the || in the template... I always use OR or AND rather than || or &&

        Comment

        Related Topics

        Collapse

        Working...