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.

Themes /

Discuss SilverStripe Themes.

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

SiteTitle and Tagline in templates


Go to End


20 Posts   12424 Views

Avatar
Miles

Community Member, 14 Posts

24 March 2010 at 11:59am

Edited: 24/03/2010 12:00pm

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

Avatar
paaa

Community Member, 2 Posts

24 March 2010 at 11:30pm

Thx guys

it worked like a charm

ta

Avatar
Patrick Arlt

Community Member, 15 Posts

27 March 2010 at 8:21am

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?

Avatar
patjnr

Community Member, 102 Posts

27 March 2010 at 8:23pm

@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

Avatar
Patrick Arlt

Community Member, 15 Posts

28 March 2010 at 8:59am

@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?

Avatar
Patrick Arlt

Community Member, 15 Posts

28 March 2010 at 9:23am

Edited: 28/03/2010 9:23am

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"))); 

Avatar
edk

Community Member, 39 Posts

28 March 2010 at 9:39am

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

Avatar
yurigoul

Community Member, 203 Posts

3 April 2010 at 10:00am

Edited: 03/04/2010 10:03am

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