/    Sign up×
Community /Pin to ProfileBookmark

Help with "if" command

On a forum I’ve installed a mod which displays a button on every post. I don’t want that button displayed on certain boards & therefore I used the following statement

[CODE]if ($context[‘current_board’] != 17)[/CODE]

This works to not display the button in board no. 17.
How do I attach more board numbers to that statement ?
Thanks.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJan 12.2017 — Not sure we have enough info to come up with a best or even correct answer for you, but I suspect what you are asking could be handled by some sort of array that you could loop through, thus avoiding a lot of repetitious if blocks.
[code=php]
$boards = array(
array('number' => 1, 'name' => 'First Board'),
array('number' => 2, 'name' => 'Second Board') // etc....
);
foreach($boards as $board) {
if($context['current_board'] != $board['number']) {
// output HTML for button to board # $board['number']
// with text $board['name']
}
}
[/code]

Ideally, the population of the $boards array in this example might come from a support function or config file, as opposed to having to stick it in the middle of your output code.
Copy linkTweet thisAlerts:
@skbauthorJan 13.2017 — Thanks ND,

Sorry I was not very clear. I have "Google+" on all Boards/Posts of my forum. I wanted to stop displaying this button in the Private Boards.

You are right, finally I had to use array to solve my problem. I eventually use this
$excludes = array(1,2,3,4,7,9,11);

if (!in_array($context['current_board'], $excludes))[/QUOTE]
×

Success!

Help @skb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...