IF ELSE syntax

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
User avatar
Vogelek23
Registered User
Posts: 64
Joined: Tue Aug 17, 2010 7:30 pm
Location: West Midlands, UK
Name: Lukas
Contact:

IF ELSE syntax

Post by Vogelek23 »

Hi all,

I want to create some IF-ELSE clause based on a multiple checks, which sets the active class only if:
- topic is not marked as solved OR, topic does not come from a Download subforum (only one of these can be true, no possibility that the topic is marked as solved and comes from Download subforum at the same time),
- topic must have unread posts.

I have created such an IF-ELSE clause:

Code: Select all

<!-- IF searchres.UNREAD_POSTS and (not searchres.DOWNLOAD_SECTION or not searchres.RESOLVED) --> (active class) <!-- ELSE --> (passive class) <!-- ENDIF -->
... but this does not work - it does not recognise Download nor Solved checks and (when it has some unread posts) automatically sets the active class even if the topic comes from Download subforum or is marked as solved. So I assume the above code has wrong syntax. What should be the right one?

In the PHP code it should be like this:

Code: Select all

if ($row['unread_posts'] && (!$row['topic_solved'] || !$row['come_from_download']))
{
 	(active class)
}
else
{
	(passive class)
}
Thanks in advance for your help!

EDIT: This code works (sets active class only if the topic has unread posts and does not come from Download section) if I remove the brackets from IF clause:

Code: Select all

<!-- IF searchres.UNREAD_POSTS and not searchres.DOWNLOAD_SECTION --> (active class) <!-- ELSE --> (passive class) <!-- ENDIF -->
EDIT 2: Went a step forward and, finally, found the proper syntax:

Code: Select all

<!-- IF searchres.UNREAD_POSTS and not (searchres.DOWNLOAD_SECTION or searchres.RESOLVED) --> (active class) <!-- ELSE --> (passive class) <!-- ENDIF -->
Now the active class is set only as intended.
Last edited by bonelifer on Sun May 05, 2019 11:15 pm, edited 1 time in total.
Reason: mark solved
Professional computer repair forum.
The largest documentation database in Europe.
FREE and professional advice from over 70k users.
Earn money for activity!
https://www.elvikom.pl
Post Reply

Return to “phpBB Custom Coding”