hi,
i only want to include the sidebar template, when i have assigned a widget to a page...
now i only have an include statement <% include Sidebar %> in my templates. how can i check if i have to include the sidebar or not?
thanks
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
hi,
i only want to include the sidebar template, when i have assigned a widget to a page...
now i only have an include statement <% include Sidebar %> in my templates. how can i check if i have to include the sidebar or not?
thanks
I do this with one of my custom page types by adding a checkbox to the "Behaviours" tab in the CMS.
CustomPage.php
class CustomPage extends Page {
static $db = array(
'DisplaySidebar' => 'Boolean'
);
static $defaults = array(
'DisplaySidebar' => true
);
function getCMSFields() {
$fields->addFieldToTab( 'Root.Behaviour', new CheckboxField('DisplaySidebar', 'Display Sidebar?') );
}
}
Then in my template:
<% if DisplaySidebar %>
<% include Sidebar %>
<% end_if %>
Cheers
Aaron
cool, thanks a lot. that helps :)