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.

All other Modules /

Discuss all other Modules here.

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

Blocks :: Using ModelAdmin to manage global contentblocks


Reply


6 Posts   1896 Views

Avatar
Martijn

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 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

Attached Files
Avatar
Pike

Community Member, 42 Posts

14 January 2010 at 4:49am

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

Avatar
mattclegg

Community Member, 56 Posts

27 January 2010 at 2:30am

Can you briefly explain how to install sample blockmanager?

Avatar
richardbowcher

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 [url=http://www.real-exams.com/Oracle.htm]braindumps oracle [/url]
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.

Avatar
UncleCheese

Forum Moderator, 4096 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?

Avatar
Pike

Community Member, 42 Posts

18 November 2010 at 7:27am

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

Thanks