Jump to:

1347 Posts in 439 Topics by 514 members

Themes

SilverStripe Forums » Themes » SiteTitle and Tagline in templates

Discuss SilverStripe Themes.

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

Page: 1 2 3
Go to End
Author Topic: 6169 Views
  • maetl
    Avatar
    Community Member
    15 Posts

    SiteTitle and Tagline in templates Link to this post

    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?

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: SiteTitle and Tagline in templates Link to this post

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

  • jeremykiveo
    Avatar
    Community Member
    5 Posts

    Re: SiteTitle and Tagline in templates Link to this post

    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

  • maetl
    Avatar
    Community Member
    15 Posts

    Re: SiteTitle and Tagline in templates Link to this post

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

  • jeremykiveo
    Avatar
    Community Member
    5 Posts

    Re: SiteTitle and Tagline in templates Link to this post

    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.

  • paaa
    Avatar
    Community Member
    2 Posts

    Re: SiteTitle and Tagline in templates Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5462 Posts
  • jeremykiveo
    Avatar
    Community Member
    5 Posts

    Re: SiteTitle and Tagline in templates Link to this post

    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!

    6169 Views
Page: 1 2 3
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.