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

24 March 2010 at 11:59am Last edited: 24 March 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". -
Re: SiteTitle and Tagline in templates

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?
-
Re: SiteTitle and Tagline in templates

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
-
Re: SiteTitle and Tagline in templates

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?
-
Re: SiteTitle and Tagline in templates

28 March 2010 at 9:23am Last edited: 28 March 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")));
-
Re: SiteTitle and Tagline in templates

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
-
Re: SiteTitle and Tagline in templates

3 April 2010 at 10:00am Last edited: 3 April 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...
| 5330 Views | ||
| Go to Top | Next > |



