Jump to:

10848 Posts in 2516 Topics by 1792 members

All other Modules

SilverStripe Forums » All other Modules » Blocks :: Using ModelAdmin to manage global contentblocks

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1791 Views
  • Martijn
    Avatar
    Community Member
    271 Posts

    Blocks :: Using ModelAdmin to manage global contentblocks Link to this post

    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
  • Pike
    Avatar
    Community Member
    40 Posts

    Re: Blocks :: Using ModelAdmin to manage global contentblocks Link to this post

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

  • mattclegg
    Avatar
    Community Member
    56 Posts

    Re: Blocks :: Using ModelAdmin to manage global contentblocks Link to this post

    Can you briefly explain how to install sample blockmanager?

  • richardbowcher
    Avatar
    Community Member
    1 Post

    Re: Blocks :: Using ModelAdmin to manage global contentblocks Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Blocks :: Using ModelAdmin to manage global contentblocks Link to this post

    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?

  • Pike
    Avatar
    Community Member
    40 Posts

    Re: Blocks :: Using ModelAdmin to manage global contentblocks Link to this post

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

    Thanks

    1791 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.