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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

new tab on tab in system


Go to End


29 Posts   10922 Views

Avatar
theAlien

Community Member, 131 Posts

30 December 2008 at 11:27am

Hi all,

I'm trying to make a new tabset on the maintab in the system, so that I can add fields to this new Root.Content.Main.Newtab-tab.
Right now I have this:

public static $db = array('Newtab' => 'TabSet');

function getCMSFields() {
  $fields = parent::getCMSFields();

  $fields->addFieldToTab('Root.Content.Main', new Tab('Newtab','Newtab',array('Tab one','Tab two',));

  return $fields; }

But that doesn't work. Does someone have a suggestion?

Avatar
Carbon Crayon

Community Member, 598 Posts

30 December 2008 at 12:46pm

Um, I don't think you can add a third level of tabs.....although I've never tried.

Is there a particular reason you cant just add it to the end of the second level of tabs?

Avatar
theAlien

Community Member, 131 Posts

30 December 2008 at 1:12pm

Hi,
Thanks for your reply. Of course I can add it to the end of the other tabs.
But I guess my users would more likely look top-down instead of left-right.
Left-right seems to be for the more advanced features (f.e. metadata - most of my users don't even know what these are, but I don't want to remove them completely).
Top-down would in that case be for the regular user.

By adding tabs on the main tab, I can force them to not overlook some fields (that are essential, but too much to add in a normal way in the main-tab)

Wow... that's quite a story. I hope you "can make chocolate out of it" (a weird dutch expression ;-) )

Avatar
Carbon Crayon

Community Member, 598 Posts

30 December 2008 at 2:42pm

hmm, I see. Well unfortunately i don't think I can help you as I've never seen this done.

perhaps one of the more experienced devs knows if it's possible?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

30 December 2008 at 5:40pm

Edited: 30/12/2008 5:41pm

I'm having a really hard time understanding what you're trying to do. Instad of this:

Content Behaviour ToDo
....Main MetaData etc
........MyTab1 MyTab2

You want this?

Content Behaviour ToDo
....Main MetaData etc
........MyTab1
........MyTab2

Where MyTab1 and MyTab2 would show/hide different fieldsets?

Avatar
theAlien

Community Member, 131 Posts

31 December 2008 at 9:08am

Edited: 31/12/2008 9:18am

Euh... now I'm having a hard time...

What I'm aiming at is:

Content is the ancestor of main
Main is the ancestor of a tabset with 2 or 3 sibling-tabs (MyTab1, MyTab2 etc)

I guess that's the first option you wrote.

The second one would be:
Content is the ancestor of main
Main is the ancestor of MyTab1
MyTab1 is the ancestor of MyTab2

And that's not what I want.

Oh! Wait! I guess I understand your hard time!
Forget my second post. I'll try to make myself clear: There is some eyetracking research out on the web that discovered people are reading text's in an F-shape; the horizontals of the F being headings and so on (as long as they understand what they are reading), the verticals of the F being the first word of every plaintext-line, and of everything they don't understand. A link: http://www.useit.com/alertbox/reading_pattern.html

I expect my backend-users to start reading the form at "Page name" and getting bored if the form appears to long.
That means a few things:
1) they would miss everything on the horizontal line of Main, Metadata etc (not only because they simply won't see it, but also because they don't understand what metadata (the second-term) are).
2) I have some formitems like startdate, starttime, enddate, endtime, contactname, contactemail, eventlocation etc. While SS is ordering formfields below eachother, it would make a pretty long form (too long for my users). So I thought about grouping them on a few tabs (a date-tab, a contact-tab etc.) It would reduce the formlength considerably, and if I order that tabset just below Navigation label (for example), it would work as a new (horizontal) 'heading' in the F-shape.
I hope this helps ;-)
(BTW: the possibility to order the shorter date- and time-fields next to each other would be a neat feature)

Avatar
UncleCheese

Forum Moderator, 4102 Posts

31 December 2008 at 9:44am

Easy enough. I'll whip up something for you when I get out of work. Give me a few hours.

I definitely agree with you about the F patterns, but I think that's why SS puts all the stuff you never use far to the right. :-)

Avatar
UncleCheese

Forum Moderator, 4102 Posts

31 December 2008 at 4:17pm

This ought to get you started. Drop this folder in your Silverstripe root and run a flush.

Usage:

$fields->addFieldToTab("Root.Content.Main", new VerticalTabSet(
new VerticalTab('Fruits', array (
new TextField('Apple'),
new TextField('Orange')
)),
new VerticalTab('Vegetables', array (
new TextField('Carrot'),
new TextField('Celery')
))
));

Let me know how that works for you.

Attached Files
Go to Top