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.

Template Questions /

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

creating new custom variable to make more admin editable text


Go to End


3 Posts   1886 Views

Avatar
martin

Community Member, 13 Posts

1 May 2010 at 12:28am

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.

Avatar
Willr

Forum Moderator, 5523 Posts

1 May 2010 at 10:04pm

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.

Avatar
martin

Community Member, 13 Posts

4 May 2010 at 7:35pm

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.