Jump to:

23452 Posts in 18901 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Edit an include in the CMS?

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: 772 Views
  • Big Bang Creative
    Avatar
    Community Member
    92 Posts

    Edit an include in the CMS? Link to this post

    I have areas of a template which are the same for all page types (i.e. quicklinks) so I have used includes. Is there a way I can make these includes editeble in the CMS or is there another way to do this?

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Edit an include in the CMS? Link to this post

    Well lots of ways people talk about editing global fields / settings, the way I prefer to do it is to make a HTMLText field on your HomePage page type (most of the time you will have a custom homepagetype, if not then just put it on page)

    mysite/code/HomePage.php

    static $db = array('QuickLinks' => 'HTMLText');

    function getCMSFields() {
    $fields = parent::getCMSFields();
    $fields->addFieldToTab('Root.Content.Main', new HTMLEditorField('QuickLinks'));
    return $fields;
    }

    After running dev/build/ and reloading the CMS you should have a HTML Editor in the CMS under the homepage for quicklinks. Then you just need to update your template so that it does

    <% control Page(home) %>
    $QuickLinks
    <% end_control %>

    That will give you the QuickLinks field on the Home Page and away you go. Other way people do it is create custom page types for the 'Site Settings' and store the field on there.

  • Big Bang Creative
    Avatar
    Community Member
    92 Posts

    Re: Edit an include in the CMS? Link to this post

    I already know how to do it this way, but it could be confusing for the client editing the homepage which will also effect the other pages.

    Doing it the "site settings" way, would it matter what is in that template, as long as I have the includes ($QuickLinks)? i.e. no divs etc.

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Edit an include in the CMS? Link to this post

    I have made a tutorial on doing this using the PageType method (i.e. creating a pagetype called 'Quicklinks' etc.), see:

    http://www.ssbits.com/create-a-static-sidebar/

    Hope that helps

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