Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » How to create a generic (editable) content block

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

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

Page: 1 2 3
Go to End
Author Topic: 5274 Views
  • Fuzz10
    Avatar
    Community Member
    786 Posts

    How to create a generic (editable) content block Link to this post

    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 !

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: How to create a generic (editable) content block Link to this post

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

  • Fuzz10
    Avatar
    Community Member
    786 Posts

    Re: How to create a generic (editable) content block Link to this post

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

  • sonicparke
    Avatar
    74 Posts

    Re: How to create a generic (editable) content block Link to this post

    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.

  • Sigurd
    Avatar
    Forum Moderator
    628 Posts

    Re: How to create a generic (editable) content block Link to this post

    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 ...

    ?

  • sonicparke
    Avatar
    74 Posts

    Re: How to create a generic (editable) content block Link to this post

    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.

  • sonicparke
    Avatar
    74 Posts

    Re: How to create a generic (editable) content block Link to this post

    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!

  • sonicparke
    Avatar
    74 Posts

    Re: How to create a generic (editable) content block Link to this post

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

    Thanks!

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