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.

Archive

Our old forums are still available as a read-only archive.

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

Variable includes


Reply

3 Posts   1567 Views

Avatar
UncleCheese

27 October 2007 at 4:26am 4085 Posts

Any way to do something like this?

<% include $URLSegment_sidebar %>

So I don't have to make a huge list like this?

<% if InSection(about) %>
<% include about_sidebar %>
<% end_if %>

< if InSection(news) %>
<% include news_sidebar %>
<% end_if %>

Ugh.. seems a little unnecessary.

Avatar
Willr

28 October 2007 at 6:23pm Forum Moderator, 5511 Posts

yep I believe you should be able to use $URLSegment (as long as people don't go changing the urls :P)

You might need to wrap the $URLSegment in curly braces {} so {$URLSegement}_sidebar to get it work.

Avatar
Sean

28 October 2007 at 8:44pm (Last edited: 28 October 2007 8:45pm), Forum Moderator, 921 Posts

Usually it's not a generally safe idea to look for templates by a $URLSegment value in it, as it's far too dynamic - especially when you're giving the site to a client who could change page names, interrupting the $URLSegment value.

And, AFAIK, there's currently no way to set in stone the page URLSegment value. A good reason to not is it's generally good SEO to make sure it's updated to reflect the content / title of the page.

Again it depends on what application you're using SilverStripe for. If it's for yourself, no problem I guess. ;-)

Sean