Een werkbalk maken voor uw component
From Joomla! Documentation
Joomla!
3.x
Opmerking: Dit is van toepassing bij het gebruik van de MVC structuur.
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(string $title, string $icon);
JToolBarHelper::deleteList(string $msg, string $task, string $alt); // Will call the task/function $task in your controller
JToolBarHelper::editList(string $task, string $alt); // Will call the task/function $task in your controller
JToolBarHelper::addNew(string $task, string $alt, boolean $check); // Will call the task/function $task in your controller
JToolBarHelper::publish(string $task, string $alt, boolean $check); // Will call the task/function $task in your controller
JToolBarHelper::unpublish(string $task, string $alt, boolean $check); // Will call the task/function $task in your controller
JToolBarHelper::preferences(string $component, integer $height, integer $width, string $alt, string $path);
- string $title → The title.
- string $msg → Postscript for the 'are you sure' message.
- string $task → An override for the task: 'controller.function'.
- string $alt → An override for the alt text.
- boolean $check → True if required to check that a standard list item is checked.
- string $component → The name of the component, eg, com_content.
Uw code zal er dus (bijvoorbeeld) als volgt uitzien:
class HelloViewHellos extends JView
{
function display($tpl = null) {
JToolBarHelper::title( 'Hello Component', 'generic.png' );
JToolBarHelper::deleteList('hellos.delete');
JToolBarHelper::editList('hellos.edit');
JToolBarHelper::addNew('hellos.add');
JToolBarHelper::publish();
JToolBarHelper::unpublish();
JToolBarHelper::preferences('com_hello', '500');
Een voorbeeld van het maken van een eigen knop in de beheerlijst met regels van uw component zou kunnen zijn: administrator/views/hellos/view.html.php
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
protected function addToolbar()
{
// assuming you have other toolbar buttons ...
JToolBarHelper::custom('hellos.extrahello', 'extrahello.png', 'extrahello_f2.png', 'Extra Hello', true);
}
administrator/controllers/hellos.php
public function extrahello()
{
// Get the input
$input = JFactory::getApplication()->input;
$pks = $input->post->get('cid', array(), 'array');
// Sanitize the input
JArrayHelper::toInteger($pks);
// Get the model
$model = $this->getModel();
$return = $model->extrahello($pks);
// Redirect to the list screen.
$this->setRedirect(JRoute::_('index.php?option=com_hello&view=hellos', false));
}
administrator/models/hello.php (opmerking: het enkelvoudige model)
public function extrahello($pks)
{
// perform whatever you want on each item checked in the list
return true;
}
Nuttige uitleg over JToolBarHelper/custom staat hier - http://docs.joomla.org/JToolBarHelper/custom