For splitting up top level menus...
class Page extends SiteTree {
public static $db = array(
'MenuGroup' => "Enum('First,Second,Third','First')"
);
function getCMSFields() {
$fields = parent::getCMSFields();
$menuField = new DropdownField(
'MenuGroup',
'MenuGroup',
singleton('Page')->dbObject('MenuGroup')->enumValues()
);
$fields->addFieldToTab("Root.Behaviour", $menuField);
return $fields;
}
...
}
class Page_Controller extends ContentController {
function menuItems($menuGroup) {
$whereStatement = "ParentID=0 AND ShowInMenus = 1 AND MenuGroup = '$menuGroup'";
return DataObject::get("Page", $whereStatement);
}
...
}
And in your template:
<% control menuItems(First) %>
$MenuTitle
<% end_control %>
Check to see if existing Pages get the default menu group set. New pages will have the default 'First'. Don't forget to rebuild!
Credit:
Saturday, September 19, 2009
Put SilverStripe Menus into Groups
Labels:
cms,
menu,
menu groups,
silverstripe,
silverstripe 2.3.3,
split menu
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment