Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: MarkoKg on September 24, 2016, 08:43:35 AM

Title: Show something everywhere except on board index?
Post by: MarkoKg on September 24, 2016, 08:43:35 AM
Hey there.

I want to add something, for example banners on all pages under the header except on front page (board index). How can I do that? I need code to be added in Index.template.php but I'm not sure if there's something like 'if curenturl is not equal to boardindexurl" statement or something similar.

Thanks!
Title: Re: Show something everywhere except on board index?
Post by: Kindred on September 24, 2016, 10:40:48 AM
not certain... but I think this would work

if (empty($context['current_action']))
Title: Re: Show something everywhere except on board index?
Post by: Arantor on September 24, 2016, 03:06:25 PM
if (empty($context['current_action']) && empty($topic) && empty($board))

Just make sure everything is in scope before trying to check them.
Title: Re: Show something everywhere except on board index?
Post by: MarkoKg on September 24, 2016, 07:20:44 PM
Just tried this, but it's not working though.


if (empty($context['current_action']) && empty($topic) && empty($board))
{
echo'banner code here';
}
echo'


$context is already in globals, just checked that. Not sure what I'm doing wrong.  :-X
Title: Re: Show something everywhere except on board index?
Post by: Arantor on September 25, 2016, 04:17:17 AM
Did you add topic and board to globals for that function?

And when you say 'not working', define 'not working', I can think of a multitude of different ways that 'not working' could play out depending on what you're doing, where and how.
Title: Re: Show something everywhere except on board index?
Post by: MarkoKg on September 27, 2016, 07:21:47 AM
Yes, topic and board are also in globals for that function, i just double-checked.

When I add the code that I wrote in previous message the banner is showing on boardIndex, and not showing on all other pages/boards/topics. What I need is vice versal - to show on all other pages and to hide it on board index.

EDIT: Gotcha, thanks!
I used:

if (empty($context['current_action']) && empty($topic) && empty($board))
{
echo'something that should be shown on board index';
}
else {
echo' banner HTML code here ';
}
Title: Re: Show something everywhere except on board index?
Post by: Paracelsus on September 27, 2016, 10:27:30 AM
Have you tried switching the instructions? The content on first echo switches with the content on else echo. ;)

Edit: ok, too late, I see you already got it. ;D