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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Changing tabs name but not the variable in templates


Reply


3 Posts   1286 Views

Avatar
servalman

Community Member, 211 Posts

23 September 2010 at 2:46am

Hello

To add a tab in the cms I usually do somethin like this :

class EditorialPage extends Page {

static $db = array(
      
      'Phrase' => 'HTMLText',

   );

}

public function getCMSFields() {
      $fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Phrase', new HtmlEditorField('Phrase'));
}

and the variable in my template is $Phrase

Now to change the name of the tab in the cms but not the variable name do I have to writte it like this :

$fields->addFieldToTab('Root.Content.AnotherName', new HtmlEditorField('Phrase')); ?

Thank you

T

Avatar
Liam

Community Member, 470 Posts

23 September 2010 at 7:13am

Yes, you change the line Root.Content.AnotherName to whatever you want. If you change 'content' to another tab that is in the CMS, it will show up under that tab.

If you want to change the label of the filed, use this:

$fields->addFieldToTab('Root.Content.AnotherName', new HtmlEditorField('Phrase', 'Whatever You Want The Label To Be'));

Avatar
stevanovich

Community Member, 60 Posts

10 November 2011 at 12:00am

Will this screw up the existing data in the database or will it just change keeping everything as is and just change the tab name? I know this is an old thread but someone may know. Cheers....