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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Can Silverstripe handle multiple content regions on a page?


Go to End


9 Posts   6966 Views

Avatar
rdr

Community Member, 7 Posts

13 January 2009 at 4:15am

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.

Avatar
Carbon Crayon

Community Member, 598 Posts

13 January 2009 at 4:27am

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

13 January 2009 at 4:29am

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.

Avatar
rdr

Community Member, 7 Posts

13 January 2009 at 4:45am

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

Avatar
rdr

Community Member, 7 Posts

14 January 2009 at 1:36am

Edited: 14/01/2009 1:54am

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.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

14 January 2009 at 3:50am

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.

Avatar
mgl

Community Member, 2 Posts

8 July 2010 at 4:14am

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.

Avatar
codemonkey88

Community Member, 24 Posts

6 March 2013 at 1:33am

Edited: 06/03/2013 1:39am

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]

Go to Top