Jump to:

23461 Posts in 18908 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Editable global data through specific pages

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

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

Page: 1
Go to End
Author Topic: 751 Views
  • Vladas
    Avatar
    Community Member
    17 Posts

    Editable global data through specific pages Link to this post

    Hello,

    I was trying to develop one part of the code but with no luck of finding the best way to do it.

    So, I have 4 pages (Home, About Us, Services, Contact Us). I want to be able to access same data on About Us, Services and Contact Us, but not in Home, while also accessing specific data to each page template.

    Imagine this, theres' diffent data shown on each page, but it keeps same company message. I could easily do it right in the template, but I also need it to be editable in CMS. Any ideas how can I do it?

    Thank You

  • Mo
    Avatar
    Community Member
    508 Posts

    Re: Editable global data through specific pages Link to this post

    If you are using the 2.4 beta release, you can create global properties by extending the SiteConfig class. If you are on 2.3 however, maybe a widget would be more useful?

    http://doc.silverstripe.org/doku.php?id=widgets

    Mo

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Editable global data through specific pages Link to this post

    Yea +1 what Mo said - thats what the SiteConfig panel in 2.4 was developed for. Trying to find a link on the wiki for it but doesn't look like its been documented yet.

    In 2.3 what I normally do for global data is make a field on the homepage page type then in the template use <% control Page(home) %>$GlobalMessage<% end_control %>. Reason I do it on the homepage is usually there a) is one and b) its singlar so 1 place to edit the data. Not perfect so hence why SiteConfig is here in 2.4!

  • Mo
    Avatar
    Community Member
    508 Posts

    Re: Editable global data through specific pages Link to this post

    All the stuff I know about SiteConfig I found out by reading inline docs and forum posts... I didn't know any other 2.4 docs existed .

    Also, I pretty much do the same in 2.3. I usually have a HomePage class that expands Page, I tend to use pretty much the same code in my template as Willr.

    Mo

    751 Views
Page: 1
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.