1282 Posts in 355 Topics by 487 members
| Go to End | Next > | |
| Author | Topic: | 5325 Views |
-
SiteTitle and Tagline in templates

17 January 2010 at 3:25am
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?
-
Re: SiteTitle and Tagline in templates

17 January 2010 at 11:55am
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).
-
Re: SiteTitle and Tagline in templates

23 January 2010 at 7:20am Last edited: 23 January 2010 7:22am
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 http://kiveo.net/extending-silverstripe-siteconfig
-
Re: SiteTitle and Tagline in templates

23 January 2010 at 7:40am
Thanks Jeremy, that's a really useful addition to this discussion.
-
Re: SiteTitle and Tagline in templates

23 January 2010 at 8:21am
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.
-
Re: SiteTitle and Tagline in templates

24 March 2010 at 12:32am
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 Footertx
AmaSol
-
Re: SiteTitle and Tagline in templates

24 March 2010 at 9:00am
See this blog entry for an example - http://www.kiveo.net/blog/extending-silverstripe-siteconfig/
-
Re: SiteTitle and Tagline in templates

24 March 2010 at 10:26am Last edited: 24 March 2010 10:28am
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!
| 5325 Views | ||
| Go to Top | Next > |




