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.

Archive /

Our old forums are still available as a read-only archive.

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

How to create a generic (editable) content block


Go to End


17 Posts   6415 Views

Avatar
Fuzz10

Community Member, 791 Posts

25 August 2007 at 2:25am

Hi,

Maybe I overlooked something in the docs, but I can't for the life of me figure out how to go about creating a single reusable and editable content block which I can include on multiple pages.

Let's say I'd like a textblock visible in the "sidebar" throughout the website. The user should be able to change the content of the block, but this content should not be page-dependent but site-dependent.

I hope my explanation is clear.

Thanks in advance !

Avatar
Ingo

Forum Moderator, 801 Posts

25 August 2007 at 6:15am

to my knowledge, there's no readymade solution to this problem (yet).
maybe something for the widget-api?
we usually declare a container-page (or just use the home-page) with an editable property that can be queried from other pages - a bit hacky, but does the trick ;)

Avatar
Fuzz10

Community Member, 791 Posts

31 August 2007 at 10:15pm

Thanks for your reply. We took the route you proposed.

Avatar
sonicparke

74 Posts

8 November 2007 at 9:55am

Can you please do a run through of how you accomplished this? I need to do the same thing and have been trying to adapt ArticlePage piece of the tutorials without success.

Avatar
Sigurd

Forum Moderator, 628 Posts

8 November 2007 at 11:03am

Do you mean you're asking how to do this:

1. add a field to the homepage, like SideBarContent
2. on all pages, fetch Homepages' SideBarContent field and put it into the template ... :)

?

Avatar
sonicparke

74 Posts

9 November 2007 at 3:50am

That makes sense I'm just not having much luck making it work. What I've done is added a new page type so the CMS has a page specifically for the sidebar content. I used the ArticlePage code from the tutorial to add the extra fields to the page. Although I've done this I'll need to change the type of field these are. I'm trying to do an "student of the month" sidebar. It would be nice to have a text box for the student's name, a box to choose the student's photo from the uploaded files, and a box for some content about the student. That way it's pretty dumb proof. I can get all this in the layout page but I'm just having trouble getting the layout page to be displayed in the template. Becasue of the variables if I use the code from the layout page it just mimics the content on each page giving me the same content twice. Hope this all makes sense.

Avatar
sonicparke

74 Posts

12 November 2007 at 12:33pm

Do you mean you're asking how to do this:

1. add a field to the homepage, like SideBarContent
2. on all pages, fetch Homepages' SideBarContent field and put it into the template ... :)

?

Yes. That's what I need to do. I know how to use the includes but I can't seem to get the data from a custom page in the CMS to the includes folder so I can use an include in the template. Unless that's the wrong way to go about it. It needs to be something really easy for a non-web-savvy user to update. Thanks!

Avatar
sonicparke

74 Posts

14 November 2007 at 6:11am

I really need some help on this if anybody has time to help me.

Thanks!

Go to Top