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.
Able to access the component button layout
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.
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.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-01-13 23:06:46 |
Closed_By | ⇒ | Quy | |
Labels |
Removed:
?
|
Please test PR #36663.