Update TemplateModel.php#40667
Update TemplateModel.php#40667BrainforgeUK wants to merge 6 commits intojoomla:4.3-devfrom BrainforgeUK:patch-12
Conversation
Avoids unexpected message on template admin.
|
I'm not a friend of creating a bunch of empty folders if I explicitly don't need them or don't want them. Simply remove the tag References:
|
This is not supported by Joomla, Joomla's own functionality WILL NEVER create a child without the expected folders. Instead of trying to bend Joomla to your way why not align your way to the Joomla's expectations? |
I suppose when removing 'mytemplate', for completness, the installer should remove everything in the following places regardless of what the manifest XML says ... it may already do that, I have not investigated! templates/mytemplate There might be other areas to which a similar installer 'for completeness' comment might apply! |
|
Then why does Joomla allow me to install a template without media files? Surely the template media files will only be relevant to the template or other template related extensions. That's an issue for template / extension developers to address. Joomla should just allow the situation without confusing messages during template testing / development. |
|
Also if you must do the magic creation either do it in the install or discover on the installer adapter: I'm not a fan of code that does something different than what is defined in the XML... |
absolutely not. its not a confusing message it is the 100% correct message. |
|
I agree a change to the installer adapter would avoid this situation happening - and would need further investigation. This change provides a safe display of an empty media location to which the admin can then add folders / files in the usual manner. A better way might be to create an empty index.html file in that location - but that does not solve the problem as index.html is not a media file! See functions getDirectoryTree() and checkFormat() ... would need an empty file called 'empty.jpg' or similar. Just discovered that if admin deletes all items under media/templates/site/mytemplate there is no way they can add something. They have to add what they want and then delete what they don't want! My solution solves that problem, although they may not want the css, images, js and sccs folders I created ,,, they still have to create what they want and delete what I created! At least they can create them. |
|
The message has not changed. The code change only avoids the message when it is unnecessary. |
Again: Joomla's own functionality produces child templates with the expected structure. To get to a point where the structure is not the expected you, probably, tried to manually create a child but missed the media folders. Joomla is not broken.
Sorry this is kinda unacceptable (imho), the templates file manager is not supposed to correct faulty XML definitions, separation of concerns. Maybe https://github.com/dgrammatiko/mod_child_export will help your situation (?).The way you produce the installable child templates is quite crucial! |
|
This is not a faulty XML definition. |
Can you post the XML? BTW, the |
|
Refer to pull request #40665 |
You know what? Enough time wasted here, do whatever you want. Unsubscribing |
administrator/components/com_templates/src/Model/TemplateModel.php
Outdated
Show resolved
Hide resolved
|
I agree with the above concerns that this PR is not the right way. But let's see if other opinions come it. |
….php Fixed PHP code style. Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
administrator/components/com_templates/src/Model/TemplateModel.php
Outdated
Show resolved
Hide resolved
….php Style correction. Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
Removed mkdir for css, image, js, sccs and replace entry result with current folder as that forces the empty folder to appear on the 'Templates: Customise' page, thus overcoming the original problem.
Replaced tabs with spaces.
|
The only correct fix as stated before is to include the media folders. |
|
That implies that the installer needs to be changed so that it either: In both cases the changes in this pull request serve 3 useful purposes which obviate the need for the above installer changes. |
administrator/components/com_templates/src/Model/TemplateModel.php
Outdated
Show resolved
Hide resolved
….php Co-authored-by: George Wilson <georgejameswilson@googlemail.com>
|
Thanks for your contribution. I'm closing this since it does unexpected magic from my point of view. You can always open it again if you think it's needed. |

Avoids unexpected message on template admin.
Pull Request for Issue #40666 .
Summary of Changes
Improved handling of getMediaFiles() function.
Testing Instructions
Install a child template without any media files.
tpl_cassiopeia_test1.zip
Actual result BEFORE applying this Pull Request
Error message on template admin page

Expected result AFTER applying this Pull Request
Link to documentations
Please select:
Documentation link for docs.joomla.org:
[*] No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
[*] No documentation changes for manual.joomla.org needed