Jump to:

23550 Posts in 19336 Topics by 2890 members

General Questions

SilverStripe Forums » General Questions » Changing tabs name but not the variable in templates

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

Page: 1
Go to End
Author Topic: 1221 Views
  • servalman
    Avatar
    Community Member
    211 Posts

    Changing tabs name but not the variable in templates Link to this post

    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

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: Changing tabs name but not the variable in templates Link to this post

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

  • stevanovich
    Avatar
    Community Member
    60 Posts

    Re: Changing tabs name but not the variable in templates Link to this post

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

    1221 Views
Page: 1
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.