17488 Posts in 4473 Topics by 1978 members
|Go to End|
31 August 2008 at 4:49am Last edited: 31 August 2008 4:52am
I made a new tab as shown in the tutorial:
$fields->addFieldToTab( 'Root.Content.Side', new HtmlEditorField( 'SideContent', 'Side Content' ) );
The tab has no proper name, it's displayed simply as "Side". When I set the locale to German, it should say "Neben-Inhalte".
I found a solution, but I wonder if there's a better one:
In FieldSet.php, I changed the addFieldToTab method, so that it no longer returns "void", but returns $tab, the tab that has been found or created by protected method FieldSet::findOrMakeTab().
Having the tab on hand, I can call $tab->setTitle( _t(...) ) :
$sideTab = $fields->addFieldToTab( 'Root.Content.Side', new TextareaField( 'FooterText', 'Footer Text', 3, 200 ) );
$sideTab->setTitle(_t('SiteTree.TABSIDE', "Side contents"));
Is there any better way to do this, without changing core functionality?
31 August 2008 at 2:25pm
could you just pass the translated tab name to the add field to tab method before rather then after you create the tab, then you dont have to mess around with the core??
Eg something like...
$myTabTitle = _t('SiteTree.TABSIDE', "Side contents");
$fields->addFieldToTab("Root.Content.". $myTabTitle ."", new TextField('Blah'));
31 August 2008 at 2:42pm
Of course, if it's that easy ... thank you! I'm new to silverstripe and I don't yet know the system exactly... This "Root.Content.Side" array key just looked like some "important" identifier to me and it probably gets parsed somewhere - so placing a translation there would have looked kind of dangerous in my eyes. I should have tried it out, though.
* Are dots allowed in the translated tab name when I do it this way?
* If I need to refer to that tab elsewhere, I will have to reference it using its translated name, right?
31 August 2008 at 2:52pm
1) No as . is the delimiter. You might want to try it out . As I would have though currently you have Root.Content.TabName so the . signifies a hierarchy. Eg the Content tab of the Base Editor has a sub tab of 'TabName'. so . I wouldn't have though would work but you never know.
2) You would have to refer to any other references of that tab as "Root.Content."._t('SiteTree.TABSIDE')."" as 'side' and 'neben-inhalte' would be difference to SS so for it to work while switching the 2 you need to use _t('SiteTree.TABSIDE') everywhere.
9 September 2008 at 8:30am Last edited: 9 September 2008 8:31am
willr, I just used your method and it works fine, but when using special characters as ø = ÃƒÂ¸ , as tab name it creates two identical tabs in the cms and puts one of my fields on the main tab...
Is there a way to make special characters work in tab-names??
|Go to Top|