Adding toolbar buttons to the backend of your component is quick and easy. Joomla! has a class named JToolBarHelper
that allows you build the toolbar one button at a time, without having to touch HTML. The buttons consist of an image, HTML, and Javascript that interacts with<form>
elements in your component.
To put JToolBarHelper
to use, we will create a set of buttons that you would normally find on a screen for managing a list of records. Open /administrator/components/com_restaurants/restaurants.php
and add the following code just before the line echo 'Restaurant Reviews':
JToolBarHelper::title( JText::_( 'Restaurant Reviews' ), 'generic.png' ); JToolBarHelper::publishList(); JToolBarHelper::unpublishList(); JToolBarHelper::editList(); JToolBarHelper::deleteList(); JToolBarHelper::addNew();
Go to Restaurant Reviews on the Components menu or hit refresh if you're already there. You should see the title Restaurant Reviews on the left, with some icons on the right...