Page 1 of 1

Not able to find replacement for mosMenuBar

Posted: Wed Sep 12, 2007 7:53 pm
by pvh123
Part of a component conversion I am working on is the replacement of the deprecated function: mosMenuBar.
I have been able to find out that this should be: JtoolbarHelper, but some of the methods used in mosMenubar are not found in JtoolBarHelper.

Also I was not able to locate JtoolBarHellper in the Framework API.
Anybody who can help me out here?

This is the old code and the methods used in it:

    mosmenuBar::startTable();   
              mosMenuBar::publishList("publish");
              mosMenubar::unpublishList("unpublish");
              mosmenubar::divider();
              mosMenubar::divider();
              mosMenubar::addNew("new");
              mosMenuBar::editList("edit");
              mosmenuBar::deleteList("","remove");
              mosMenubar::spacer();
              mosmenubar::endTable();

Re: Not able to find replacement for mosMenuBar

Posted: Sun Sep 16, 2007 5:46 pm
by ianmac
What methods are you missing?

JToolBarHelper is the class that you want, but it isn't part of the framework API.  It is application specific.  Look at the core components as examples and look at administrator/includes/toolbar.php for reference.  Note that the toolbar is a JToolBar helper, so it is possible to get a reference to the toolbar instance and add buttons that way as well.

Ian

Re: Not able to find replacement for mosMenuBar

Posted: Mon Sep 24, 2007 10:08 am
by pvh123
ianmac wrote:What methods are you missing?


It is for instance "starttable" method that fires 
undefined method JToolBarHelper::starttable()

error because that method does not exits with JToolbarhelper.
I can see what you mean from the core components, but do not seem to see how to adapt that to my code.
I have attached the toolbar.php and the html file. I would appriciate it very much if you could have a look and start me of with an example.

Thanks, Pieter

Re: Not able to find replacement for mosMenuBar

Posted: Mon Sep 24, 2007 2:26 pm
by ianmac
Hey,

There is no replacement for the starttable method because it is no longer required.  This is automatically handled by the toolbar class.

Here is an example from the core components:
                // Set toolbar items for the page
                JToolBarHelper::title(  JText::_( 'Weblink Manager' ), 'generic.png' );
                JToolBarHelper::publishList();
                JToolBarHelper::unpublishList();
                JToolBarHelper::deleteList();
                JToolBarHelper::editListX();
                JToolBarHelper::addNewX();
                JToolBarHelper::preferences('com_weblinks', '360');
                JToolBarHelper::help( 'screen.weblink' );

That is all the code you need for your toolbar.

Let me know if you have any further questions.  This is generally done in MVC in the view, but it can still be done with the toolbar.example.php file and the toolbar.example.html.php file.

Ian

Re: Not able to find replacement for mosMenuBar

Posted: Mon Sep 24, 2007 3:56 pm
by pvh123
Great, Ian. I will have a go at it let you know how it works out.

Edit:

Worked like a dream!