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.

Template Questions /

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

Different Includes Based on Logic?


Go to End


2 Posts   1740 Views

Avatar
Garrett

Community Member, 245 Posts

14 October 2009 at 6:58am

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

Avatar
Willr

Forum Moderator, 5523 Posts

14 October 2009 at 1:25pm

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