Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Themes /

Discuss SilverStripe Themes.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

If else ?


Go to End


3 Posts   2690 Views

Avatar
mommek

Community Member, 9 Posts

20 July 2010 at 3:45am

Hi,

I need do this:

<?php

if ($_GET['page'] == 'news')
{
do nothink
}
else{
generate submenu
}

?>

.......

I have 5 main pages -> 2 of them have submenu ... I want show only 1 of them submenu.. second -> I dont wanna generate in html submenu.

I know, that it is possible turn-off in admin (show in menus - on/off) but I can't change this..

Avatar
Willr

Forum Moderator, 5523 Posts

20 July 2010 at 1:16pm

Do you need to do this in the template? or in the cms?. In the front end you need to write a function which detects the get var (are you sure you want to use get and not the URLParams ?) so in Page.php something like

function IsNews() {
return isset($_GET['news']);
}

Then in the template you can do <% if IsNews %> ... <% else %>... <% end_if %>

Avatar
mommek

Community Member, 9 Posts

21 July 2010 at 2:09am

thx a lot, I solve this problem with:

<% if Pos != 2 %>