avatar BrainforgeUK
BrainforgeUK
7 Jan 2022

Steps to reproduce the issue

Create a module which uses button layout from a component.

The module can can displayed on any page with any component, not just views from its related component, although the module will not work if its related component is not installed.

Expected result

Able to access the component button layout

Actual result

Unabled to access the component button layout.

This because no options are passed to the FileLayout constructor and it uses the currently displayed component by default.

Have to override the renderButton() method in ToolbarButton and classes which extend it. Ok, achieves the objective but lots of code duplication as cannot use parent::renderButton() anywhere as ToolbarButton is at the bottom of the class extension tree.

System information (as much as possible)

Additional comments

Suggested solution:
In renderButton() method of Joomla\CMS\Toolbar\ToobarButton replace line 214

$layout = new FileLayout($this->layout);

with

$layout = $this->getFileLayoutInstance($this->layout);

The new getFileLayoutInstance() method would be defined as follows:

protected function getFileLayoutInstance($layoutId, $basePath = null, $options = null)
{
return new FileLayout($layoutId, $basePath, $options);
}

This will allow any class which extends Joomla\CMS\Toolbar\ToobarButton and/or Joomla\CMS\Toolbar\popupButton to customise the FileLayout object (or even extend that class) in any way required.

There maybe other classes where FileLayout is used in a similar way and applying the same technique there might also prove useful.

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
5.00

avatar BrainforgeUK BrainforgeUK - open - 7 Jan 2022
avatar Quy Quy - change - 13 Jan 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-01-13 23:06:46
Closed_By Quy
Labels Removed: ?
avatar Quy Quy - close - 13 Jan 2022
avatar Quy
Quy - comment - 13 Jan 2022

Please test PR #36663.

Add a Comment

Login with GitHub to post a comment