Jump to:

1385 Posts in 493 Topics by 522 members

Themes

SilverStripe Forums » Themes » If else ?

Discuss SilverStripe Themes.

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

Page: 1
Go to End
Author Topic: 1706 Views
  • mommek
    Avatar
    Community Member
    9 Posts

    If else ? Link to this post

    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..

  • Willr
    Avatar
    Forum Moderator
    5511 Posts

    Re: If else ? Link to this post

    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 %>

  • mommek
    Avatar
    Community Member
    9 Posts

    Re: If else ? Link to this post

    thx a lot, I solve this problem with:

    <% if Pos != 2 %>

    1706 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.