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: 6187 Views
  • Miles
    Avatar
    Community Member
    14 Posts

    Re: SiteTitle and Tagline in templates Link to this post

    Jeremy, I can very that this does in fact work.

    $fields->addFieldToTab("Root.Main", new TextField("AddressLn1", _t('SiteConfig.ADDRESSLN1',"Address Ln 1")));
    $fields->addFieldToTab("Root.Tab", new TextField("AddressLn2", _t('SiteConfig.ADDRESSLN2',"Address Ln 2")));


    Address line two now shows up in another tab just after access called "Tab".

  • paaa
    Avatar
    Community Member
    2 Posts

    Re: SiteTitle and Tagline in templates Link to this post

    Thx guys

    it worked like a charm

    ta

  • Patrick Arlt
    Avatar
    Community Member
    15 Posts

    Re: SiteTitle and Tagline in templates Link to this post

    I tried extending the dataobject like this in the 2.4 beta 2 and it doesn't work it adds the corrent database fields but the fields do not show up in the backend did something change?

  • patjnr
    Avatar
    Community Member
    101 Posts

    Re: SiteTitle and Tagline in templates Link to this post

    @Patrick if you do it like this it will work.

    put this line in _config.php

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

    create a page called SiteConfigOverride .php in mysite/code and paste the code below

    <?php
    class SiteConfigOverride extends DataObjectDecorator{
    function extraStatics() {
    return array(
             'db' => array(
                "Telephone1" => "Varchar(255)",
                "Telephone2" => "Varchar(255)",
                "HotOffer" => "Text",
    )
    );
    }

    public function updateEditFormFields(FieldSet &$fields) {
    $fields->addFieldToTab("Root.SiteConfiguration", new TextField("Telephone1", _t('SiteConfig.TELEPHONE1',"Telephone 1")));
    $fields->addFieldToTab("Root.SiteConfiguration", new TextField("Telephone2", _t('SiteConfig.TELEPHONE2',"Telephone 2")));
    $fields->addFieldToTab("Root.SiteConfiguration", new TextareaField("HotOffer", _t('SiteConfig.HOTOFFER',"Bottom zone text")));
    }
    }

    ?>

    then rebuild your DB and flush your cache

    ta

  • Patrick Arlt
    Avatar
    Community Member
    15 Posts

    Re: SiteTitle and Tagline in templates Link to this post

    @PatJnr

    Humm, I tried it your way just copied and pasted the code ran /dev/build and visited /admin?flush=1 and nothing. The database entries are built but the fields still do not show up.

    Just to remove variables from the equation I downloaded a fresh copy of Silverstripe from Silverstripe.org and tried the same procedure. Nothing. Database fields are built but the form fields do not show up in the backend.

    Does anyone else have this error? Can you get it working in beta2?

  • Patrick Arlt
    Avatar
    Community Member
    15 Posts

    Re: SiteTitle and Tagline in templates Link to this post

    I ended up looking at the SiteConfig.php file and found this comment

       /**
        * Get the fields that are sent to the CMS. In
        * your decorators: updateCMSFields(&$fields)

        *
        * @return Fieldset
        */

    so its this...

       public function updateCMSFields(&$fields){
          $fields->addFieldToTab("Root.Main", new TextField("Telephone1", _t('SiteConfig.TELEPHONE1',"Telephone 1")));
          $fields->addFieldToTab("Root.Main", new TextField("Telephone2", _t('SiteConfig.TELEPHONE2',"Telephone 2")));
          $fields->addFieldToTab("Root.Main", new TextareaField("HotOffer", _t('SiteConfig.HOTOFFER',"Bottom zone text")));
       }

    Not...

    public function updateEditFormFields(FieldSet &$fields) {
          $fields->addFieldToTab("Root.Main", new TextField("Telephone1", _t('SiteConfig.TELEPHONE1',"Telephone 1")));
          $fields->addFieldToTab("Root.Main", new TextField("Telephone2", _t('SiteConfig.TELEPHONE2',"Telephone 2")));
          $fields->addFieldToTab("Root.Main", new TextareaField("HotOffer", _t('SiteConfig.HOTOFFER',"Bottom zone text")));
       }

    Adding new tabs works also.

          $fields->addFieldToTab("Root.Contact", new TextField("Telephone1", _t('SiteConfig.TELEPHONE1',"Telephone 1")));

  • edk
    Avatar
    Community Member
    39 Posts

    Re: SiteTitle and Tagline in templates Link to this post

    Thanks Patrick,

    I had been playing with this for the last few days. In the 2.4Beta 1 release the syntax provided in the earlier posts works fine...I was starting to think it may have been a bug in the 2.4 Beta 2 release...but your digging shows it was a slight change.

    -Ed

  • yurigoul
    Avatar
    Community Member
    202 Posts

    Re: SiteTitle and Tagline in templates Link to this post

    Just changed it a bit to include links to sitetree to build the main menu:

    function extraStatics() {
    return array(
    'has_one' => array(
    'Portfolio' => 'SiteTree'
    )
    );
    }

    public function updateCMSFields(&$fields) {
    $fields->addFieldToTab("Root.Menu", new TreeDropdownField("PortfolioID", "Portfolio", "SiteTree"));
    }

    EDIT: not that I have use for it now -so therefor I am not trying it right now - but I am wondering if we can include complextablefields, DOM etc...

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