21279 Posts in 5729 Topics by 2600 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 866 Views |
-
check for widgets in template

23 March 2009 at 9:08am
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
-
Re: check for widgets in template

25 March 2009 at 5:41pm
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
| 866 Views | ||
|
Page:
1
|
Go to Top |


