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.

Themes

Discuss SilverStripe Themes.

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

SiteTitle and Tagline in templates


Go to End
Reply

20 Posts   6657 Views

Avatar
maetl

17 January 2010 at 3:25am Community Member, 15 Posts

I'm upgrading a site to 2.4alpha, and so far I'm very impressed with the faster CMS loading and page interactions...

I notice that there are new settings fields on the SiteTree root by default – Title and Tagline. This is useful, but I can't seem to figure out how to access these variables in the Page/template scope.

The blackcandy theme still has the tagline embedded as text in the HTML templates.

Any suggestions how to access these fields?

Avatar
Willr

17 January 2010 at 11:55am Forum Moderator, 5511 Posts

You can access any Site Config settings by using $SiteConfig.SettingName - eg $SiteConfig.Title, $SiteConfig.Tagline.

The template should have been updated with the correct code in branches/2.4 (the actual alpha download will still have the issue).

Avatar
jeremykiveo

23 January 2010 at 7:20am (Last edited: 23 January 2010 7:22am), Community Member, 5 Posts

Oh my goodness, I heart the Site Config -- just discovered it in 2.4alpha last night and spent all night haXXoring and came up with a brilliant (if I do say so myself) way of extending it via the Data Object Decorator (thank-you, thank-you, thank-you to the SS Team for dreaming up this beauty! you've saved me SOOOO much time!). I just wanted to share how I got extra fields into the Site Config screen really quickly for anyone who might be looking:

In mysite/_config.php, add the line

DataObject::add_extension('SiteConfig', 'SiteConfigOverride');

In mysite/code/ create a file called "SiteConfigOverride.php" and put the following into it:

<?php
class SiteConfigOverride extends DataObjectDecorator{
function extraStatics() {
      return array(
            "AddressLn1" => "Varchar(255)"
         )
      );
   }

   public function updateEditFormFields(FieldSet &$fields) {
      $fields->addFieldToTab("Root.Main", new TextField("AddressLn1", _t('SiteConfig.ADDRESSLN1',"Address Ln 1")));
   }
}
?>

I've found that you need to have the closing PHP tag in this file or SS dies a horrible white screen death without throwing errors, but that's ok, b/c it only took 5 mins to fix. Hopefully this will help someone that was in my situation. I've posted a fuller tutorial-ish explanation on our site at [url]http://kiveo.net/extending-silverstripe-siteconfig[/url]

Avatar
maetl

23 January 2010 at 7:40am Community Member, 15 Posts

Thanks Jeremy, that's a really useful addition to this discussion.

Avatar
jeremykiveo

23 January 2010 at 8:21am Community Member, 5 Posts

I saw the Site Config and just knew that it would be great for adding semi-static content for customers to "update their templates" without having to call me when they move or need to change a telephone number. I just see this as enabling the end users to really focus more on design than data.

Avatar
paaa

24 March 2010 at 12:32am Community Member, 2 Posts

Hi

is it possible to add new tabs along side Main and Access.
Im trying to add a tab which will contain HtmlEditorField for a Footer

tx

AmaSol

Avatar
Willr

24 March 2010 at 9:00am Forum Moderator, 5511 Posts

See this blog entry for an example - http://www.kiveo.net/blog/extending-silverstripe-siteconfig/

Avatar
jeremykiveo

24 March 2010 at 10:26am (Last edited: 24 March 2010 10:28am), Community Member, 5 Posts

Not having tried it myself, I think this is what you're getting at?

In the updateEditFormFields method in the example, you'd change the text "Root.Main" to "Root.NewTab". My question (again, not having tried it myself) would be: Is it necessary to execute findOrMakeTab('Root.NewTab') prior to adding content to it?

Thanks!

Go to Top