IF Statements

Tutorials for phpBB3. Try the Tutorials here and share Your own Tutorials
There is no support here! Only Read Access!
User avatar
Post Bot
BBCoder IV
BBCoder IV
Posts: 248
Joined: 04 Mar 2010, 18:53

IF Statements

Post by Post Bot » 10 Mar 2010, 15:52

Here is the if statements that was posted by RMcGirr83 originally. Plus some addons by Stoker.

<!-- IF S_USER_LOGGED_IN --> If a user is logged in
<!-- IF S_REGISTERED_USER --> If user is logged in and not a bot
<!-- IF S_AUTOLOGIN_ENABLED --> If auto login is allowed
<!-- IF S_BOARD_DISABLED --> If board is disabled
<!-- IF S_IS_BOT --> If a bot
<!-- IF S_USER_PM_POPUP --> If pop up pm is on
<!-- IF S_DISPLAY_SEARCH --> If displays search
<!-- IF S_DISPLAY_PM --> If display a PM
<!-- IF S_DISPLAY_MEMBERLIST --> If display memberlist.php
<!-- IF U_MCP --> If Moderator
<!-- IF U_ACP --> If Administrator
<!-- IF S_IS_LINK --> If its a link
<!-- IF S_UNREAD_FORUM --> If forum is unread
<!-- IF S_READ_FORUM --> If forum is read
<!-- IF S_LOCKED_FORUM --> If forum is locked
<!-- IF S_LIST_SUBFORUMS --> If there is a list of subforums
<!-- IF S_SUBFORUMS --> If a subforum
<!-- IF S_IS_CAT --> If a category
<!-- IF S_IS_POST --> If a post
<!-- IF FORUM_ID --> Displays the code between the switches if the user is viewing a particular forum.
<!-- IF SCRIPT_NAME == "index" -->some content<!-- ENDIF --> (Others you can use, viewtopic,viewforum,memberlist,faq etc)
<!-- IF S_USERNAME eq 'Stoker' -->Some content here<!-- ENDIF -->


Examples

Let's say you wanted something to show in an html file for registered users only, then you could use the following

Code: Select all

<!-- IF S_REGISTERED_USER -->Hello, welcome to blahblah.com<!-- ENDIF -->
Which will only show to registered users.

or

Code: Select all

<!-- IF FORUM_ID eq 2 -->Welcome to Forum Number 2<!-- ENDIF -->
Which will only show if the viewer is within Forum Id #2.

You can also combine the IF's

Code: Select all

<!-- IF FORUM_ID eq 2 and S_REGISTERED_USER -->Welcome to Forum ID #2 and you are a registered user<!-- ENDIF -->
Also, you can use the following operands as well

or ( || )
and ( && )
eq ( == )

You can use either the language ones (or, and, eq) or the other ones ( ||, &&, ==).

Remember each time you have a <!-- IF something --> statement you must also have an ending <!-- ENDIF --> statement, else you will get errors when the templating engine does it's stuff.

this could be copied to tuturials.


TiTex
BBCoder II
BBCoder II
Posts: 5
Joined: 29 Mar 2010, 12:29

Re: IF Statements

Post by TiTex » 18 Aug 2010, 19:13

is there an IF statement like <!-- IF U_ACP --> but instead of if admin to be if not admin ?
or is there another way to show a link or some content to everybody beside administrators ?
Last edited by TiTex on 18 Aug 2010, 19:15, edited 1 time in total.

User avatar
Steve
BBCoder VI
BBCoder VI
Posts: 803
Joined: 04 Mar 2010, 23:10
Extra Rank: Donator.png
BBCodes: 2000
Favourite BBCode: porn tube
Favourite MOD: Non of Stokers
Location: up your bum

Re: IF Statements

Post by Steve » 18 Aug 2010, 19:34

use

Code: Select all

<!-- IF not U_ACP -->some text!<!-- ENDIF -->
NAPWR wrote: Nice, Stoker is Hot

TiTex
BBCoder II
BBCoder II
Posts: 5
Joined: 29 Mar 2010, 12:29

Re: IF Statements

Post by TiTex » 18 Aug 2010, 20:49

thx for the quick reply but i used if else like this
IF U_ACP some text ELSE some other text ENDIF

User avatar
Steve
BBCoder VI
BBCoder VI
Posts: 803
Joined: 04 Mar 2010, 23:10
Extra Rank: Donator.png
BBCodes: 2000
Favourite BBCode: porn tube
Favourite MOD: Non of Stokers
Location: up your bum

Re: IF Statements

Post by Steve » 19 Aug 2010, 08:32

yes that works so you used :

Code: Select all

<!-- IF U_ACP --><!-- ELSE -->some text!<!-- ENDIF -->
both codes work in the same way but the above code would be more usefull if you wanted to show 2 messages for example:

Code: Select all

<!-- IF U_ACP -->Good day admin please dont pump.<!-- ELSE -->Good day everyone,admin has been told not to pump.<!-- ENDIF -->
NAPWR wrote: Nice, Stoker is Hot


TiTex
BBCoder II
BBCoder II
Posts: 5
Joined: 29 Mar 2010, 12:29

Re: IF Statements

Post by TiTex » 21 Aug 2010, 06:38

yes , that's what i was trying to acomplish ... a message for admin eyes only and another for everybody else

User avatar
Wildthinks
BBCoder II
BBCoder II
Posts: 9
Joined: 08 Mar 2010, 18:38

Re: IF Statements

Post by Wildthinks » 05 Sep 2010, 17:16

is there an IF statement for groups?
I'd like to hide some profile fields - so only users in specific groups should see it in the topics.

User avatar
Steve
BBCoder VI
BBCoder VI
Posts: 803
Joined: 04 Mar 2010, 23:10
Extra Rank: Donator.png
BBCodes: 2000
Favourite BBCode: porn tube
Favourite MOD: Non of Stokers
Location: up your bum

Re: IF Statements

Post by Steve » 05 Sep 2010, 17:22

try:

Code: Select all

<!-- IF GROUP_ID eq 3 -->
change the number 3 to suit your needs
multiple groups would be

Code: Select all

<!-- IF GROUP_ID eq 3 or 4 -->
NAPWR wrote: Nice, Stoker is Hot

cisco007
BBCoder VI
BBCoder VI
Posts: 1015
Joined: 16 Mar 2010, 16:14
Location: Don't really know!

Re: IF Statements

Post by cisco007 » 05 Sep 2010, 17:34

no you have to do a little more than that i think Steve! I guess wildthinks you didn't search the board hard enough look here!

viewtopic.php?f=9&t=460

User avatar
Wildthinks
BBCoder II
BBCoder II
Posts: 9
Joined: 08 Mar 2010, 18:38

Re: IF Statements

Post by Wildthinks » 05 Sep 2010, 17:37

Thank you =)

@cisco: Think you're right... after searching through german phpBB support, I was so tired... I think I haven't seen it :D