Jump to content


- - - - -

RESOLVED: IF Statement help


  • Please log in to reply
5 replies to this topic

#1 TCC

TCC

    Coder

  • IM Supporters
  • PipPipPipPipPip
  • 107 posts
  • IPB Version:v2.3.x

Posted 23 September 2007 - 10:36 PM

I would like some code to appear for all user groups accept 3.

This works for one group:

CODE
<if="$this->ipsclass->member['g_id'] != 4"><br /></if>


and I tried this for 3 groups but no luck:

CODE
<if="$this->ipsclass->member['g_id'] != 4 || $this->ipsclass->member['g_id'] != 9 || $this->ipsclass->member['g_id'] != 12"><br /></if>


Any ideas? Thanks in advance.

#2 Martin

Martin

    But but, it's not only only!

  • Management
  • PipPipPipPipPipPipPipPipPipPip
  • 7,081 posts
  • Location:Hammerfest, Norway
  • Real Name:Martin Aronsen
  • IPB Version:v3.2.x
Contributor

Posted 24 September 2007 - 12:56 AM

CODE
<if="$this->ipsclass->member['mgroup'] != 3">Foobert!</if>



EDIT: Oh, may be you ment ALL groups expect  for three groups? || or OR should work. I've seen it many times in the default templates (At least I think so). If not:
CODE
<if="$this->ipsclass->member['mgroup'] != 3"><if="$this->ipsclass->member['mgroup'] !=4"><if="$this->ipsclass->member['mgroup'] != 5">Foobert!</if></if></if>

Not recommended  to do it so, since it's pretty horrible.

Edited by m4rtin, 24 September 2007 - 12:59 AM.


#3 Sean

Sean

    The One Man Show - IB.Bored

  • IM Supporters
  • PipPipPipPipPipPipPipPipPipPip
  • 3,857 posts
  • Location:England, UK
  • Real Name:Sean Ellis
  • IPB Version:v2.3.x
Contributor

Posted 24 September 2007 - 01:03 AM

Cleaner way:
CODE
<if="! in_array( intval( $this->ipsclass->member['mgroup'] ), array( 3, 4, 5 ) )">
    <!-- Content -->
</if>

Posted Image

My Free Modifications | For Sale Modifications | Photos of Moi | Services System

My computer is messed up. I can't develop anything until I get my grubby paws a new computer.

I do not offer support via PM or any other messenger service. Please use the forums.


#4 Phun

Phun

    Novice

  • Members
  • PipPip
  • 8 posts
  • Real Name:Johan
  • IPB Version:v2.3.x

Posted 20 January 2011 - 09:51 AM

Got it working by using this code:

<if="$this->ipsclass->member['mgroup'] == 1 OR $this->ipsclass->member['mgroup'] == 5">Hello World!</if>

You should not be able to see this now, but when you change
member['mgroup'] == 5

to
member['mgroup'] == 4

You should be able to (as RooT admin).

The numbers are the GROUP ID numbers and you can add as many as you want by adding more "OR" variables.


[Holy cows i just saw i bumped up a really old topic, sorry!]

Edited by Phun, 20 January 2011 - 09:52 AM.


#5 AndyF

AndyF

    Cogito ergo sum

  • Management
  • PipPipPipPipPipPipPipPipPipPip
  • 8,414 posts
  • Location:Derby, UK
  • Real Name:Andy
  • IPB Version:v3.2.x
Contributor

Posted 20 January 2011 - 10:25 AM

View PostPhun, on 20 January 2011 - 09:51 AM, said:

[Holy cows i just saw i bumped up a really old topic, sorry!]
:lol: I'd noticed.

I'll mark it resolved. ;)

View my tutorials

Please do NOT pm me with support related questions unless requested.
If you are in need of help or assistance, please post on the forum in the appropriate section!



A Look Back - 1.0.1 - 1.3.1 - 2.0.0 - 2.1.7 - 2.2.0 - 2.3.6

#6 AndyF

AndyF

    Cogito ergo sum

  • Management
  • PipPipPipPipPipPipPipPipPipPip
  • 8,414 posts
  • Location:Derby, UK
  • Real Name:Andy
  • IPB Version:v3.2.x
Contributor

Posted 20 January 2011 - 10:25 AM

The issue this topic was opened for has now been resolved. :)

View my tutorials

Please do NOT pm me with support related questions unless requested.
If you are in need of help or assistance, please post on the forum in the appropriate section!



A Look Back - 1.0.1 - 1.3.1 - 2.0.0 - 2.1.7 - 2.2.0 - 2.3.6




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users