Jump to:

3444 Posts in 1030 Topics by 871 members

Template Questions

SilverStripe Forums » Template Questions » creating new custom variable to make more admin editable text

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

Page: 1
Go to End
Author Topic: 1243 Views
  • martin
    Avatar
    Community Member
    13 Posts

    creating new custom variable to make more admin editable text Link to this post

    Possibly a very simple question:

    I'm building my very first SilverStripe website. I'm using the default "BlackCandy" as my starting point and slowly converting the graphics and CSS to our design.

    The "BlackCandy" template(s) have the "Your Site Name" and "your site's tagline here" elements within the main Page.ss file. That's fine for static content pulling information solely from that .ss file. But let's say that the site's "tagline" is something that changes quite frequently and it would be best/easiest if that was an editable text area within the CMSs Admin area.

    I can see the $Content variable within the Page.ss file (which obviously pulls text from the "Content" area of the database... but I can't see how to make another area similar to $Content.

    The SilverStripe online demo has a homepage has 7 separate "content" areas - "Content", "LeftBoxText", "LeftImage", "MiddleBoxText", "MiddleImage", "RightBoxText" and "RightImage".

    If I wanted a "LeftBoxText" variable - how would I go about making it? I assume that it's custom made for the demo...?

    I've seen something about having to add something to the Page.php file (in MySite) along the lines of:

    static $db = array(
    'Date' => 'Date',
    'Author' => 'Text'

    But i'm obviously not doing something right as that's not working for me.

    Any help/advice greatly received.

    Regards,
    Martin.

  • Willr
    Avatar
    Forum Moderator
    5502 Posts

    Re: creating new custom variable to make more admin editable text Link to this post

    Have a read of tutorial 2 for how to add fields to the CMS. In 2.4 the Site Title and the Site Tagline are in the CMS on the SiteConfig panel so you don't need to edit the templates to change it.

  • martin
    Avatar
    Community Member
    13 Posts

    Re: creating new custom variable to make more admin editable text Link to this post

    Hi,

    Thanks for the reply.

    I'm currently using v2.3.7 (isn't 2.4 still in beta? Can't really use a beta for a "real" job for a client).

    I have read through tutorial and I'm not sure I fully understand (more my lack of coding knowledge than any suggestion the tutorial is poor).

    I'm hoping someone would treat me like a REAL amateur at this and give me a simple point-by-point example of creating a custom variable. I'm sure once I've done one (and it works) producing any more after that will be easy.

    Cheers,
    m.

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