Creating a toolbar for your component: Difference between revisions
From Joomla! Documentation
No edit summary |
DeanMarshall (talk | contribs) m Minor edit - removal of extraneous quotes |
||
| Line 3: | Line 3: | ||
By default the Joomla Toolbar uses a Delete, Edit, New, Publish, Unpublish and Parameters buttons. To use them in your component you must write the following code in the view.html.php of your view file (below your display function). | By default the Joomla Toolbar uses a Delete, Edit, New, Publish, Unpublish and Parameters buttons. To use them in your component you must write the following code in the view.html.php of your view file (below your display function). | ||
<source lang="php"> | <source lang="php"> | ||
JToolBarHelper::title( | JToolBarHelper::title( 'your_component_view_page_title', 'generic.png' ); | ||
JToolBarHelper::deleteList(); // Will call the task/function "remove" in your controller | JToolBarHelper::deleteList(); // Will call the task/function "remove" in your controller | ||
JToolBarHelper::editListX(); // Will call the task/function "edit" in your controller | JToolBarHelper::editListX(); // Will call the task/function "edit" in your controller | ||
| Line 9: | Line 9: | ||
JToolBarHelper::publishList(); // Will call the task/function "publish" in your controller | JToolBarHelper::publishList(); // Will call the task/function "publish" in your controller | ||
JToolBarHelper::unpublishList(); // Will call the task/function "unpublish" in your controller | JToolBarHelper::unpublishList(); // Will call the task/function "unpublish" in your controller | ||
JToolBarHelper::preferences('your_component_xml_file', | JToolBarHelper::preferences('your_component_xml_file', 'height'); | ||
</source> | </source> | ||
So (i.e.) your code would look like this: | So (i.e.) your code would look like this: | ||
Revision as of 19:04, 7 August 2010
Note: This applies when using the MVC structure.
By default the Joomla Toolbar uses a Delete, Edit, New, Publish, Unpublish and Parameters buttons. To use them in your component you must write the following code in the view.html.php of your view file (below your display function).
JToolBarHelper::title( 'your_component_view_page_title', 'generic.png' );
JToolBarHelper::deleteList(); // Will call the task/function "remove" in your controller
JToolBarHelper::editListX(); // Will call the task/function "edit" in your controller
JToolBarHelper::addNewX(); // Will call the task/function "add" in your controller
JToolBarHelper::publishList(); // Will call the task/function "publish" in your controller
JToolBarHelper::unpublishList(); // Will call the task/function "unpublish" in your controller
JToolBarHelper::preferences('your_component_xml_file', 'height');
So (i.e.) your code would look like this:
class HelloViewHellos extends JView
{
function display($tpl = null) {
global $mainframe, $option;
JToolBarHelper::title( 'Hello Component', 'generic.png' );
JToolBarHelper::deleteList();
JToolBarHelper::editListX();
JToolBarHelper::addNewX();
JToolBarHelper::publishList();
JToolBarHelper::unpublishList();
JToolBarHelper::preferences('com_hello', '500');