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.

Customising the CMS /

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

How can this be achieved? Repeatable content blocks


Go to End


4 Posts   1564 Views

Avatar
Olliepop

Community Member, 5 Posts

6 July 2014 at 4:52pm

Edited: 06/07/2014 5:22pm

Hi there,

I want to achieve repeatable content blocks on a page. These 'sections' of a page comprise of an image, a title, and the content. I want them to be editable from the page editor in the CMS. This seems easily achievable by making these sections work like blog posts, where you write a post then attach it to a category (in this case a page) but it should be possible do this by adding and removing tabs (Root.Section_1, Root.Section_2 ... etc) for the Page Type in the CMS (instead of the sections having their own area of the CMS and being difficult for those who aren't technically inclined to manage).

What I've tried is creating a new DataObject 'Section.php' and Page type 'SectionedPage.php'. What I'm having trouble with is adding/removing tabs (by using action buttons?) and associating 'sections' with the page ID. The template 'SectionedPage.ss' loops through Sections associated with the page ID.

The purpose of this functionality is for an editable parallax scrolling website. The image is a big background image, the title appears ontop of the image (which will scroll with a parallax effect) and the content appears in a regular space below the image.

Any insight would be greatly appreciated

Avatar
Willr

Forum Moderator, 5523 Posts

6 July 2014 at 7:25pm

Adding and removing tabs is probably not the way to go, you may want to use a GridField for managing dataobjects on the page. Or if you care about versioning and draft stages then creating subpagees is the way to go down the page.

Lot's of modules trying to do this pattern https://github.com/burnbright/silverstripe-widgetpages is one.

Avatar
Olliepop

Community Member, 5 Posts

7 July 2014 at 12:02am

Thanks Willr, yeah it's looking like GridField is the best option. I'm still going to take a crack at adding/removing tabs as it's best for usability, will update with progress if I go down that path.

Avatar
Olliepop

Community Member, 5 Posts

13 July 2014 at 2:27pm

Update: I ended up doing subpages of page type 'PageSection' under page type 'SectionedPage'. PageSection includes a CMS field called 'weighting' which determines the order of sections on a SectionedPage. Most basic solution, I figured that the time saved implementing will be greater than the time spent explaining how to use it.