Not able to find replacement for mosMenuBar

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
User avatar
pvh123
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Not able to find replacement for mosMenuBar

Post by pvh123 » Wed Sep 12, 2007 7:53 pm

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();
;) pieter

User avatar
ianmac
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: Not able to find replacement for mosMenuBar

Post by ianmac » Sun Sep 16, 2007 5:46 pm

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
Help test my Component XML Generator Tool!
http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,1997/Itemid,35/
All feedback appreciated!

User avatar
pvh123
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: Not able to find replacement for mosMenuBar

Post by pvh123 » Mon Sep 24, 2007 10:08 am

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
Attachments
toolbar.zip.zip
(1.24 KiB) Downloaded 58 times
;) pieter

User avatar
ianmac
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: Not able to find replacement for mosMenuBar

Post by ianmac » Mon Sep 24, 2007 2:26 pm

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
Help test my Component XML Generator Tool!
http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,1997/Itemid,35/
All feedback appreciated!

User avatar
pvh123
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: Not able to find replacement for mosMenuBar

Post by pvh123 » Mon Sep 24, 2007 3:56 pm

Great, Ian. I will have a go at it let you know how it works out.

Edit:

Worked like a dream!
Last edited by pvh123 on Fri Oct 12, 2007 7:20 am, edited 1 time in total.
;) pieter


Post Reply