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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Blocks :: Using ModelAdmin to manage global contentblocks

Go to End

6 Posts   2238 Views


Community Member, 271 Posts

18 September 2009 at 10:12pm

Edited: 18/09/2009 10:18pm

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 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 (requires new controls when extending the blocks).
Adding a Tab for selecting pages where to display the Block.

What do you think?

For making TinyMCE to work in ModelAdmin I needed this patch:

Attached Files

Community Member, 42 Posts

14 January 2010 at 4:49am

Very interesting for me.
Will you continue to develop it?


Community Member, 56 Posts

27 January 2010 at 2:30am

Can you briefly explain how to install sample blockmanager?


Community Member, 1 Post

20 April 2010 at 6:36pm

Edited: 20/04/2010 6:36pm

This looks like exactly what I need but I'm completely unfamiliar with this level of CMSMS development so could do with some help Embarrassed.Basically, I have a sidebar that contains, in the top half, the news summary from the news module. Below that, I want the website editors to be able to edit what appears in the lower half of the sidebar.I tried adding a content block ({content block="Sidebar"}) to that section of the sidebar. When I went to braindumps oracle
edit one of the pages, I had a 'Sidebar' text area and that worked fine. However what I wanted was for that content block to then be repeated on all the pages that use the sidebar, without manually going through them all.

Which is what brought me here.


Forum Moderator, 4102 Posts

21 April 2010 at 1:40am

I use ManyManyDOM to manage callouts on every page, and the nice thing is they're extendible, and since 2.4, you can drag-and-drop sort them uniquely on any page, and it's all in CMSMain, so you can be looking at a given page and see its associated callouts.

Would that be code you guys would be interested in seeing?


Community Member, 42 Posts

18 November 2010 at 7:27am

I've very big interes.
Can I see code, instructions, examples?