Jump to:

23459 Posts in 18906 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Can Silverstripe handle multiple content regions on a page?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1 2
Go to End
Author Topic: 3677 Views
  • rdr
    Avatar
    Community Member
    7 Posts

    Can Silverstripe handle multiple content regions on a page? Link to this post

    I'm currently evaluating SilverStripe and have been unable to find an answer to this -- maybe because I can't think of a succinct way to phrase it. I have two requirements:

    1. Suppose I have a content page which has a wide area for the main page content, and then, to its side, a narrow column where I'd like content editors to be able to create page-specific content (related links, call-to-action graphics, etc).

    2. Similar scenario to the above, but suppose I want my narrow column to be a generic global block that content editors can edit. In other content management systems (e.g. CMS Made Simple) these are referred to as Global Content Blocks. I understand the SS concept of includes, but can these be edited inside the software?

    Really grateful if anyone can point me in the right direction. I've worked through the Level 1 and Level 2 tutorials and like what I see; really hoping I can use SS for some client projects.

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Can Silverstripe handle multiple content regions on a page? Link to this post

    Hi rdr, welcome to the Silverstripe forums!

    You can do both of those things. If you want a second page specific content area you can add another HTMLEditorField to the Page class in Page.php

    If you want a generic sidebar which is editable in the CMS, you can do what I described in this thread: http://www.silverstripe.org/customising-the-cms/show/252007

    Hope that helps, if you have any more questions just ask

  • UncleCheese
    Avatar
    4085 Posts

    Re: Can Silverstripe handle multiple content regions on a page? Link to this post

    Well, this is the great thing about Silverstripe. When they say "template freedom" this is what they're referring to. Other CMS's try to usher you into their pre-cooked opinions of how a page should look and the nomenclature that they use to define it, e.g. "global content blocks." There's no such thing in SS. You do with your template what you want, because every page type and the components that make it up are a reflection of a database structure.

    So to answer your question, there are a million ways to do it. If you just want generic content, here's the easiest way:

    code/Page.php

    static $db = array (
    'SideContent' => 'HTMLText'
    )
    function getCMSFields()
    {
    $fields = parent::getCMSFields();
    $fields->addFieldToTab("Root.Content.Sidebar", new HTMLEditorField('SideContent','Sidebar content'));
    return $fields;
    }

    and of course on your template

    <div class="sidebar">$SideContent</div>

    If you want to get into something more rich like adding custom objects (like a "link" object with a title, URL, description, for instance) or syndicating content from elsewhere on the site, that's also very easy, but this should get you started.

  • rdr
    Avatar
    Community Member
    7 Posts

    Re: Can Silverstripe handle multiple content regions on a page? Link to this post

    Aram and UncleCheese, cheers fellas; plenty there for me to start playing around with.

  • rdr
    Avatar
    Community Member
    7 Posts

    Re: Can Silverstripe handle multiple content regions on a page? Link to this post

    Thanks again guys, I've got this working a treat.

    Looking at the SS documentation, I can't see a user entry point for what I think are very common needs for extending page templates (static content blocks, multiple editable regions on a page). There's almost the assumption that you're a PHP programmer and will get the "big picture" of the programming model. I wonder how true that reality is for a good amount of people who are tasked with implementing a CMS and building sites?

    I'm a designer who can hack scripts and configure a Linux webserver pretty well, but I'm not a PHP programmer and have no desire to be one. I think it would be great if some clever people extended articles in the wiki to include some more prefab PHP code for what are every day needs for most websites. The tutorial covering a news page (for example), is great.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Can Silverstripe handle multiple content regions on a page? Link to this post

    I agree. The news module tutorial is definitely the best place to start. I work with a designer, who also has an allergy to PHP code, and when he's in a jam, he just duplicates the code from that tutorial.

    But you do make a good point. This is definitely a programmer's CMS. There's no way around it. My hope is that someday SS takes the ExpressionEngine3 model and makes a UI for building data models and CMS interfaces, rather than just leaving it to "obscure" PHP code.

  • mgl
    Avatar
    Community Member
    2 Posts

    Re: Can Silverstripe handle multiple content regions on a page? Link to this post

    Hi -
    I'm not sure this thread is still active, but I have a similar problem.
    I'm new to Silverstripe.

    The site I've built has an "About Us" page and a "Our Products" page.
    My customer wants the Home Page to have (amongst other things) two columns that contain the About Us and Our Products headings together with the first 50 words or so from the respective pages.

    It seems very similar to the News tutorial, and also close to the suggestions made here, but I've not had much luck in implementing either to be what I want.

    Help appreciated.

  • codemonkey88
    Avatar
    Community Member
    13 Posts

    Re: Can Silverstripe handle multiple content regions on a page? Link to this post

    I have been trying to add a sidebar to my pages, but whenever I click save, the editor just blanks itself. No entities or anything, just plain text but it won't save anything.

    static $has_one = array(
    'SideBar' => 'HTMLText'
    );
       

    function getCMSFields() {
    $fields = parent::getCMSFields();
    $fields->insertBefore(new Tab('SideBar', 'Side Bar'), 'Metadata');
    $fields->addFieldToTab("Root.Content.SideBar", new HTMLEditorField('SideBar', 'Side Bar Content'));

    return $fields;
    }

    [edit]
    Sorry guys, turns out I don't understand the difference between $db and $has_one. Managed to get it working anyway.
    [/edit]

    3677 Views
Page: 1 2
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.