Jump to:

23364 Posts in 18125 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Add a space in tab name

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: 1459 Views
  • Big Bang Creative
    Avatar
    Community Member
    92 Posts

    Add a space in tab name Link to this post

    How do I add a space into the tab name? I have created a tabset and added some more tabs as below but I could really do with there been spaces in the tab names (parent & child).

    <?php

    class HomePage extends Page {
    static $db = array(
    'Box1Thumbnail' => 'HTMLText',
    'Box1Link' => 'HTMLText',
    'Box2Thumbnail' => 'HTMLText',
    'Box2Link' => 'HTMLText',
    'Box3Thumbnail' => 'HTMLText',
    'Box3Link' => 'HTMLText',
    'Box4Thumbnail' => 'HTMLText',
    'Box4Link' => 'HTMLText'
    );
    static $has_one = array(
    );

    function getCMSFields() {
    $fields = parent::getCMSFields();
    $fields->addFieldToTab('Root', new TabSet('HomePageBoxes'));
    $fields->addFieldToTab('Root.HomePageBoxes.Box1', new HTMLEditorField('Box1Thumbnail', 'Thumbnail'));
    $fields->addFieldToTab('Root.HomePageBoxes.Box1', new HTMLEditorField('Box1Link', 'Link'));
    $fields->addFieldToTab('Root.HomePageBoxes.Box2', new HTMLEditorField('Box2Thumbnail', 'Thumbnail'));
    $fields->addFieldToTab('Root.HomePageBoxes.Box2', new HTMLEditorField('Box2Link', 'Link'));
    $fields->addFieldToTab('Root.HomePageBoxes.Box3', new HTMLEditorField('Box3Thumbnail', 'Thumbnail'));
    $fields->addFieldToTab('Root.HomePageBoxes.Box3', new HTMLEditorField('Box3Link', 'Link'));
    $fields->addFieldToTab('Root.HomePageBoxes.Box4', new HTMLEditorField('Box4Thumbnail', 'Thumbnail'));
    $fields->addFieldToTab('Root.HomePageBoxes.Box4', new HTMLEditorField('Box4Link', 'Link'));

    return $fields;
    }
    }
    class HomePage_Controller extends Page_Controller {
       
    }
    ?>

  • Howard
    Avatar
    Community Member
    215 Posts

    Re: Add a space in tab name Link to this post

    I take it you have tried just adding spaces? If that doesn't work then try it with double commas " not ' around the title.

    Like:   
       $fields->addFieldToTab("Root.Home Page Boxes.Box1", new HTMLEditorField('Box1Thumbnail', 'Thumbnail'));

    Any joy?

  • Big Bang Creative
    Avatar
    Community Member
    92 Posts

    Re: Add a space in tab name Link to this post

    Yes I did try it with spaces lol and it did not work

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Add a space in tab name Link to this post

    When I do this in my ContactForm page:

    $fields->addFieldToTab('Root.Content.ContactForm', new TextField('Name', 'Name'));

    the tab name will read 'Contact Form'. Tried this with other names as well - seems a space is added by using capitals (v2.3) Won't work with numbers I guess...

  • Big Bang Creative
    Avatar
    Community Member
    92 Posts

    Re: Add a space in tab name Link to this post

    Your adding to "Content" which will put the text field under the content box which works fine. I am adding fields to a new tab which I still cannot get spaces in.

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Add a space in tab name Link to this post

    TabSet takes a second parameter upon construction that will be used as Title (if it's a string).

    So, you could do the following:

    $fields->addFieldToTab('Root', new TabSet('HPBoxes', 'Home Page Boxes'));
    $fields->addFieldToTab('Root.HPBoxes.Box1', new HTMLEditorField('Box1Thumbnail', 'Thumbnail'));
    ...   

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