User tests: Successful: Unsuccessful:
This PR has influence on #30468 and #30464
This PR will prevent duplicate code.
Both layouts/joomla/button/iconclass.php
and layouts/joomla/toolbar/iconclass.php
are the same.
Merging both will make our code a bit DRY
Apply the PR and go to Joomla administrator or Joomla frontend and look for icons on buttons or in a toolbar.
There should be no change visible before or after applying the PR.
Buttons in the toolbar have icons
Buttons in the toolbar have icons
The newly created Layout joomla.icon.iconclass
has two parameters
use Joomla\CMS\Layout\LayoutHelper;
echo LayoutHelper::render('joomla.icon.iconclass', ['icon' => 'fa-folder-open', 'html' => true]);
this will render
<span class="fas fa-folder-open" aria-hidden="true"></span>
use Joomla\CMS\Layout\LayoutHelper;
echo LayoutHelper::render('joomla.icon.iconclass', ['icon' => 'fa-folder-open']);
this will render
fas fa-folder-open
use Joomla\CMS\Layout\LayoutHelper;
echo LayoutHelper::render('joomla.icon.iconclass', ['icon' => 'published', 'html' => true ]);
this will render
<span class="fas fa-check" aria-hidden="true"></span>
use Joomla\CMS\Layout\LayoutHelper;
echo LayoutHelper::render('joomla.icon.iconclass', ['icon' => 'published' ]);
this will render
fas fa-check
Status | New | ⇒ | Pending |
Category | ⇒ | Layout Libraries |
Title |
|
Labels |
Added:
?
|
@brianteeman This PR reduces duplicate code but keeps the possibility to override the origin.
Developers still can both toolbar/iconclass.php and button/iconclass.php the way they did before.
Both files echo the icon/iconclass.php
Both files where exactly the same and there is no use of maintaining two equal files.
We should try not to repeat ourself while coding.
content of layouts/joomla/toolbar/iconclass.php
=== content of layouts/joomla/button/iconclass.php
Only that should be reason enough to merge it into one file.
Files being identical is a consequence of the layouts concept.
Can the button still be overridden separately to the toolbar?
Can the button still be overridden separately to the toolbar?
yes.. I haven't deleted both files. The only echo the new layout. You can override button/iconclass to your own template and go wild in the code. Same goed for toolbar/iconclass
I have tested this item
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC
Labels |
Added:
?
|
Status | Ready to Commit | ⇒ | Pending |
Back to pending status as requested by the author.
Labels |
Removed:
?
|
I have tested this item
#30468
and
now merged with this pr so will close them.
I have tested this item
works as expected
merged recent 4.0-dev updates and solved merge conflict
I have tested this item
I have tested this item
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-09-11 08:41:59 |
Closed_By | ⇒ | infograf768 | |
Labels |
Added:
?
|
Thanks
Clearly the current code is not optimal but is merging the layouts the solution? I thought the whole point of layouts was that they were single purpose and could be overridden. Doesn't this change prevent that?