Unit/System Tests PR-6.3-dev Pending

User tests: Successful: Unsuccessful:

avatar HLeithner
HLeithner
26 Aug 2026
  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

All written by hand...

Summary of Changes

Add couple of methods to the Toolbar class which allow to easily add buttons at a specific position relative to an existing button.

new methods:

    public function getButtonByName(string|array $names, $parent = self::GET_BUTTON_PARENT_ROOT, ?ToolbarButton $parentButton = null): ToolbarButton
    public function insertButtons(int $offset, ToolbarButton $referenceButton, ToolbarButton ...$buttons): void
    public function insertButtonsBefore(ToolbarButton $referenceButton, ToolbarButton ...$buttons): void
    public function insertButtonBefore(ToolbarButton $referenceButton, ToolbarButton $button): ToolbarButton
    public function insertButtonsAfter(ToolbarButton $referenceButton, ToolbarButton ...$buttons): void
    public function insertButtonAfter(ToolbarButton $referenceButton, ToolbarButton $button): ToolbarButton

This will not work if the reference button already added to the toolbar is not a ToolbarButton for example legacy code might used the plain array syntax which is deprecated since a long time and will be removed with 7.0

Testing Instructions

in your HTMLView of a list view add an override for the addToolbar() method

protected function addToolbar()
{
    parent::addToolbar();

    $toolbar = $this->getDocument()->getToolbar();

    $button = new StandardButton('save-copy', 'JTOOLBAR_SAVE_AS_COPY');
    $button
        ->listCheck(true)
        ->task('items.save2copy');

    $toolbar->insertButtonAfter($toolbar->getButtonByName('save-group', $button));
    // or as alternative add it into the action drop down
    $toolbar->insertButtonAfter($toolbar->getButtonByName('unpublish', Toolbar::GET_BUTTON_PARENT_BUTTON), $button);
}

Actual result BEFORE applying this Pull Request

Not possible to you need to create it by hand

Expected result AFTER applying this Pull Request

Should add the button at the right position

Link to documentations

Please select:

  • Documentation link for guide.joomla.org:

  • No documentation changes for guide.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar HLeithner HLeithner - open - 26 Aug 2026
avatar HLeithner HLeithner - change - 26 Aug 2026
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 26 Aug 2026
Category Libraries
avatar brianteeman
brianteeman - comment - 26 Aug 2026

silly question - buttons are rendered in the order they are written in the code - so why would i put the code out of order and use these new methods instead?

avatar HLeithner
HLeithner - comment - 26 Aug 2026

silly question - buttons are rendered in the order they are written in the code - so why would i put the code out of order and use these new methods instead?

If you have a Plugin for example or use the parent:: addtoolbar default toolbar and want to add additional buttons in your own component and in worse case in an override (not a good idea but who knows)

avatar HLeithner HLeithner - change - 26 Aug 2026
Labels Added: PR-6.3-dev
avatar brianteeman
brianteeman - comment - 26 Aug 2026

So would I be correct then that this could be used here

public static function jooa11y($url = '', $updateEditors = false, $icon = 'icon-universal-access', $bodyHeight = null, $modalWidth = null)
{
$bar = Toolbar::getInstance('toolbar');
// Add a button.
$bar->appendButton('Popup', $icon, 'Preview', $url . '&task=preview', 640, 480, $bodyHeight, $modalWidth);

so that inbstead of appending the button it could be placed in a specific place

avatar brianteeman
brianteeman - comment - 26 Aug 2026

So would I be correct then that this could be used here

public static function jooa11y($url = '', $updateEditors = false, $icon = 'icon-universal-access', $bodyHeight = null, $modalWidth = null)
{
$bar = Toolbar::getInstance('toolbar');
// Add a button.
$bar->appendButton('Popup', $icon, 'Preview', $url . '&task=preview', 640, 480, $bodyHeight, $modalWidth);

so that instead of appending the button it could be placed in a specific place

avatar HLeithner
HLeithner - comment - 26 Aug 2026

So would I be correct then that this could be used here

public static function jooa11y($url = '', $updateEditors = false, $icon = 'icon-universal-access', $bodyHeight = null, $modalWidth = null)
{
$bar = Toolbar::getInstance('toolbar');
// Add a button.
$bar->appendButton('Popup', $icon, 'Preview', $url . '&task=preview', 640, 480, $bodyHeight, $modalWidth);

so that instead of appending the button it could be placed in a specific place

yes, but in core we don't have a good example, maybe the guided tour, since it has a custom build toolbar in the view.

avatar joomla-cms-bot joomla-cms-bot - change - 26 Aug 2026
Category Libraries Libraries Unit Tests
avatar HLeithner HLeithner - change - 27 Aug 2026
Labels Added: Unit/System Tests
avatar HLeithner HLeithner - change - 27 Aug 2026
Title
[6.3] Allow inserting buttons at specific positions
[6.3] Allow inserting toolbar buttons at specific positions
avatar HLeithner HLeithner - edited - 27 Aug 2026

Add a Comment

Login with GitHub to post a comment