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

Adding custom HTML elements to Home Page.


Go to End


2 Posts   1315 Views

Avatar
kcclemo

Community Member, 1 Post

30 September 2016 at 4:12am

Hello all,
I am trying to put together a layout for the home page that would require the editor to insert code snippets that style some basic services based on a custom CSS class.

What I can't find a nice way to provide is a way for them to edit these snippets with the information about the service and an image and add them to the front page in a way that doesn't require them to know any coding at all. A good example is this bootstrap demo page that has the circle images and paragraphs under the carousel slider:
http://getbootstrap.com/examples/carousel/

I can't find a way to provide an interface for the user to add those headings.
Maybe a holder class that includes all the children of the home page? And each child page could contain the content of the headings?

Not sure how best to approach this in SilverStripe's framework.

Avatar
blackduck

Community Member, 13 Posts

24 October 2016 at 8:55pm

If you're planning to have a view details link to the content like the example, then a child page for each sounds like a good plan.
If the blocks are only being displayed on the home page then having a class for the section and add it to the homepage with a has_many relationship and a gridfield in the cms might be better.

In your home page template you'll be looping through either the child pages or the objects, doesn't really matter which.

holder/children
https://www.silverstripe.org/learn/lessons/the-holderpage-pattern?ref=hub

Has many dataobject
https://www.silverstripe.org/learn/lessons/working-with-data-relationships-has-many?ref=hub