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.

Template Questions /

include a own sidebar in just one page section


Go to End
Reply


12 Posts   3121 Views

Avatar
martin_w

Community Member, 28 Posts

21 September 2009 at 7:52pm

hello,

I have a question about a own sidebar (not the blog sidebar).
For example:
I have the following pages in my cms:
Home
News
Contact

So, I ceated a sidebar and I want this sidebar only include in the news section, and also on all sublinks from the news section.
My question is now how I can include the sidebar and tell silverstripe its just to show on news (and sublinks from news).
My sidebar file is called "NewsSidebar.ss"

I hope you can understand my question and I hope I posted in the right forum,
regards from germany.

Avatar
Willr

Forum Moderator, 5513 Posts

21 September 2009 at 9:59pm

You could do

<% control Level(1) %>
<% if Title = News %>
... show sidebar
<% end_if %>
<% end_control %>

Avatar
martin_w

Community Member, 28 Posts

22 September 2009 at 1:28am

hi,

thanks for your answer..
but what is about the sub pages of "News".. they have other titles, so the sidebar would not be included, right?

Avatar
ardjan

Community Member, 9 Posts

22 September 2009 at 1:57am

I think you can use the InSection-control for that.

Avatar
martin_w

Community Member, 28 Posts

22 September 2009 at 3:27am

I searched for "In section control" in the silverstripe docu ( http://doc.silverstripe.org/doku.php ), but I found nothing about it.

so, could you please tell me more about that function?

Avatar
Willr

Forum Moderator, 5513 Posts

22 September 2009 at 1:29pm

"News".. they have other titles, so the sidebar would not be included, right?

No because that code is controlling over the Level(1) it returns the titles of the top most level pages.

InSection would work well for this - http://doc.silverstripe.com/doku.php?id=built-in-page-controls&s=insection.

<% if InSection(blog) %>
....
<% end_if %>

Avatar
martin_w

Community Member, 28 Posts

22 September 2009 at 8:10pm

thanks, that works how I wanted. :)

Avatar
NARKOZ

Community Member, 25 Posts

22 February 2010 at 10:39pm

Hi. Thanks.

How can I do this for different pages. I guess, for forum and blog pages something like:

<% if InSection(forum) or InSection(blog) %>
            $Layout
<% else %>
         <div id="main">
            $Layout
         </div>
   
            <% include SideBar %>
<% end_if %>

but it doesn't work and gives me error.

Go to Top