Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » new tab on tab in system

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

Page: 1 2 3 4
Go to End
Author Topic: 6370 Views
  • theAlien
    Avatar
    Community Member
    131 Posts

    Re: new tab on tab in system Link to this post

    Hi,

    I'm impressed! I don't think I could come up with that (yet).
    At least it seams I really was thinking to easy about it.

    Thanks alot for all your hard work!

    Right now I'm trying to get it working.
    The 'Hi' alert from the js is showing already (even twice), so that's a good thing I guess.
    However the vertical tabs aren't there yet.

    I've added the unpacked zip to localhost/silverstripe/
    The example usage-code went into function getCMSFields() {}
    And I added Text-columns for Apple, Orange, Carrot and Celery to the database (public static $db = array() )

    I tried adding tab and/or tabset-columns to the db, but that gave errors while flushing.

    Do I forget something?

    Update: I removed the line (4) with alert('hi'); from the js-file, but (even after flushing and refreshing) I get the hi-alert twice ^o|

  • UncleCheese
    Avatar
    4085 Posts

    Re: new tab on tab in system Link to this post

    Can you post your entire PHP class for the page you're working on?

    Haha.. sorry about the alert('hi').. gotta love debugging.

  • UncleCheese
    Avatar
    4085 Posts

    Re: new tab on tab in system Link to this post

    Sorry, I just missed your last point about adding columns to the DB. That is not how it's used. This is just for the visual presentation -- not the actual data. The tabs and tabsets are NOT data types. They're form fields.

  • theAlien
    Avatar
    Community Member
    131 Posts

    Re: new tab on tab in system Link to this post

    Hi,
    Thanks for you're reply's. I'll dig further into it tomorrow (or the day after).
    Right now I'm heading for some newyears eve-parties (though the forum says it's already jan 1st, here in europe it's still 31 december)

    Best wishes to you and all other SilverStripers and be save

  • theAlien
    Avatar
    Community Member
    131 Posts

    Re: new tab on tab in system Link to this post

    Hi again,

    Back again, and it's 2009!

    On topic: While doing it, I wasn't sure at all about adding tab or tabset to the db. It was more or less an experiment, just in case I was missing something - well, I wasn't, because it didn't work (and you said so too). Or were you also talking about adding the apple, orange etc. to db? That would make everything a little more complex to me. They are meant to populate the db, aren't they (just like in the tutorials: $fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content'); and $db = array('Author' => 'Text'); in a way belong together)

    Below is the whole class (basically a copy-paste of your class), and in the attachment a screenshot of what is showing up (just before I clicked the hi-alert away - I kind of love those debugging things too, so I left it in for now ;) ).

    <?php
    /*
    * Defines the PageTest page type
    */
    class PageTest extends Page {
       public static $db = array(
          'Apple' => 'Text',
          'Orange' => 'Text',
          'Carrot' => 'Text',
          'Celery' => 'Text',
       );
       public static $has_one = array(
       );
       
       function getCMSFields() {
          $fields = parent::getCMSFields();

          $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')
       ))
       ));
       
          
          return $fields;
       }
    }

    class PageTest_Controller extends Page_Controller {
    }
    ?>

    Might it be that I'm developing for the 2.3rc2?

    Attached Files
  • theAlien
    Avatar
    Community Member
    131 Posts

    Re: new tab on tab in system Link to this post

    Eureka!!!
    It had something to do with both the vertical_tabset.js and the images not showing up.

    As soon as I not only commented out line 4 (alert('hi'); in the .js-file but also the surrounding lines 3-6, there were (all of a sudden) the so much wanted fruit and vegetable-fields. Searching a little bit further learned me, they were always there, nicely hidden in their folded harmonica tabs. But because of a lack of images and headings on those tabs, I didn't see them.

    Which means: I just have to dig a little further, bring up the images and the headings (that should be doable) and it's up and running! Seems to be a CSS-thing after all.

    --

    Update: Well... OK... not that much of a eureka. The (easy) CSS part is solved. But now I'm desperately searching for a way to connect the Formfields Apple, Orange etc. to their own db-columns... And that - of course - is why this all started. At least it isn't as easy as just filling the $db = array() anymore

  • UncleCheese
    Avatar
    4085 Posts

    Re: new tab on tab in system Link to this post

    Glad it's working for you. You can style the h3 tags any way you like. I just chose to keep it consistent with the SS theme. The default state is open for the h3, but if you add the class "closed" it will render its closed state (arrow up).

    I'd like to see any changes you add to it, then I'll post it on my website. Pretty cool idea. Thanks for thinking of it!

  • theAlien
    Avatar
    Community Member
    131 Posts

    Re: new tab on tab in system Link to this post

    Thanks.
    I will definitely post any changes.
    In terms of layout I'm thinking about making everything a bit lighter and more blueish. The grey is very good if the vertical tabs are situated at the bottom, but imo that's a bit overdone if the vertical tabs are let's say just above $content. Maybe a little border around the tabs would also be a good idea...

    But that's not what I'm concerned with right now. Because - in order to get it usefull to me and anyone else - the formfields in the tab(sets) should be able to save something to the database (because that's what the cms is for after all). I think I have to extend the Save and Publish page handler in LeftandMain.php (from line 428). Or maybe this discussion you and Aram started http://silverstripe.org/customising-the-cms/show/251460 could be of some use. But to be honest, I stuck right now.

    6370 Views
Page: 1 2 3 4
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.