Every backend view in Joomla has control over the toolbar area appearing just above the main output. This toolbar is controlled through some helper functions that make it impossible to mess up.
So let's login to the backend and add some toolbars to our Places view now. Let's go to Components>Noida City>Places.
Here we have the list view that we have already built in our previous tutorial and we are just going to add a toolbar up here at the top, so that we have some buttons that we can use on these records.
So go to administrator>components>com_noidacity>views and replace the code of view.html.php file with the following lines of code.
So after you replace and save view.html.php file go back to the backend and hit Refresh and magically you see a title for the screen and you see all of these different toolbar buttons. So let's see what actually happened.
First, we have the title function of JtoolBarHelper. This JtoolBarHelper::title function is receiving one argument and that is the title that we want to display. So we are using JText to translate the language string COM_NOIDACITY_PLACES_TITLE and its returning Noida City Places that's being displayed here on the left.
And then next we have addNew edit list, a divider, publishList, unpublishList, a divider then archiveList and trash, it displays all these different toolbar buttons along with divider so we can visually separate different tasks. So for instance, we have a New task and an Edit task here and we want to visually separate that from the publishing and the unpublishing and we definitely want to separate that from trash. All we had to do was add these functions and Joomla takes care of displaying the buttons.
The arguments that we are passing into these functions are the task names that we want to assign to these buttons. So what will happen is whatever we click on say editList button that is going to tell Joomla to fire off the Place Edit task.
Adding toolbars to your Joomla component is simplified through the use of standard functions. You don't have to worry about getting the markup right or lining things up, the class handles this automatically. When you create toolbar buttons, they're loaded with tasks and when clicked, those buttons submit the task along with the form.