17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1284 Views |
-
Variable includes

27 October 2007 at 4:26am
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.
-
Re: Variable includes

28 October 2007 at 6:23pm
yep I believe you should be able to use $URLSegment (as long as people don't go changing the urls
)
You might need to wrap the $URLSegment in curly braces {} so {$URLSegement}_sidebar to get it work.
-
Re: Variable includes

28 October 2007 at 8:44pm Last edited: 28 October 2007 8:45pm
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
| 1284 Views | ||
|
Page:
1
|
Go to Top |


