// Define the button JToolbarHelper::custom('myButton', 'myButtonIcon', '', 'My Button', false); // Define the button function function myButton() { echo "Hello World!"; }
// Define the menu items $bar = JToolBar::getInstance('toolbar'); $bar->appendButton('Menu', 'My Menu'); $bar->appendButton('Separator'); // Add items to the menu $bar->addButton(array( 'text' => 'Menu Item 1', 'link' => 'index.php?option=com_myextension&view=myview&id=1' )); $bar->addButton(array( 'text' => 'Menu Item 2', 'link' => 'index.php?option=com_myextension&view=myview&id=2' ));This code will add a toolbar menu with the label "My Menu". When clicked, the menu will show the items "Menu Item 1" and "Menu Item 2", which will link to different views of the "myextension" component. Package library: Joomla! Framework, specifically the JToolbarHelper class.