Hi all,
Im experimenting with a module to add extendable contentblocks which are global accessible on different template positions on the website. ( Like Joomla does with modulespositions and SS does with widgets, but with a central admin section in the CMS)
I'm curious about your opion about my approach:
Use ModelAdmin to administer blocks, templatepositions and css classes (css needs some rethinging).
A Block class which is extendable to add functions like a searchblock, menublock, loginblock.
Each Block can be set to display on page selection or all pages (loggedin/loggedout?) (Not yet implemented)
I made a working example, but needs some adjustments.
Current usage:
Install the block module.
In the cms (MainMenu blocks) add your cssclasses and template positions and add some general contentblocks( with template position and css class)
In Page_Controller add:
function Blocks($pos = 'header') {
return DataObject::get("Block", "Active = 1 AND Position = '".$pos."'");
}
In your theme Page.ss add your desired blockpositions like:
<% control Blocks(header) %>
<% include Blocks %>
<% end_control %>
where header is a theme positions like footer, left, right etc.
I added a zip with a sample blockmanager and some extended Block classes for a MainMenuBlock and SearchBlock.
Some TODO's:
Using RenderWith instead of a switch in Blocks.ss (requires new controls when extending the blocks).
Adding a Tab for selecting pages where to display the Block.
What do you think?
Edit::
For making TinyMCE to work in ModelAdmin I needed this patch:
http://open.silverstripe.com/attachment/ticket/3586/ModelAdmin.js