Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » Different Includes Based on Logic?

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

Page: 1
Go to End
Author Topic: 1135 Views
  • Garrett
    Avatar
    Community Member
    245 Posts

    Different Includes Based on Logic? Link to this post

    Hi,

    I am currently trying to load different include files based on some simple logic using InSection() but it's not working at ALL. In my main Layout/Page.ss template, I am including a file called SideBarChooser, which then has this logic inside it:

       <% if InSection(solutions) %>
       <% include SideBarSolutions %>
       <% else_if InSection(clients) %>
       <% include SideBarClients %>
       <% else_if InSection(industries) %>
       <% include SideBarIndustries %>
       <% else_if InSection(newsroom) %>
       <% include SideBarNewsroom %>
       <% else %>
       <% include SideBar %>
       <% end_if %>

    In some cases ALL the SideBars are being painted to the screen; in others, it just plain doesn't work. Anyone have any idea what's wrong with this?

    Thanks,
    Garrett

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Different Includes Based on Logic? Link to this post

    Are any of these pages children of pages in that list? If so then InSection() could return true multiple times.

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