Joomla 4.1 changed the way template files are stored. Some files are moved to the media folder. We develop our own templates.
When we upload our (scaffolding) J4 template throught FTP (we changed it to use the new media loocations) we do not see the preview images in the backend. We used the 'discover' feature to install the template.
The Cassiopeia template thumnai is located here (and shown correctly):
/media/templates/site/cassiopeia/images/template_thumbnail.png
Our template thumbnail is located here, but the images is not shown:
/media/templates/site/bbgb/images/template_thumbnail.png
In the source we see:
<img src="" alt="Voorbeeld" style="width:200px; height:120px;">
How do we let Joomla know where the images is located? Is this a fixed location (like it was) , in that case our thumbnail should be found, right?
Or do we need to add the preview images path somewhere? Maybe in the template XML?
Labels |
Added:
No Code Attached Yet
|
Thanks @Bakual.
I added the 1 line to the tmeplate XML. But this did not solve the issue of the missing thumbnail image. When I cehck the source code I also do nit see the code that is added to create the modal. And the image is missing. Not sure why.
I also had some issues with loading template assets on out template. Assets with a direct URL were loaded but local assets were not loaded. But after add the 1 line in the XML and reinstalling (discovering) the template this seems to have been fixed. I was struggling with that as well. But this works OK now. Excellent!
So the only the template preview image is not working for me at this point. That;s not a huge issue because it doesn not impact the template. It's just not showing the preview image(s).
I tried replacing our images with the cassiopeia images but that did not work. So it's not an image issue. Not sure where to look next...
We also had a template installed on a J 4.0 version (not using the new assets loication) and after the update to 4.1 the preview image was gone also.
@dgrammatiko Any ideas?
On Joomla 4.0:
<?xml version="1.0" encoding="utf-8"?>
<extension type="template" client="site">
<name>Hof van Welbevinden</name>
<version>1.0</version>
<creationDate>Januari 2022</creationDate>
<author>Inxpact</author>
<authorEmail>info@inxpact.nl</authorEmail>
<authorUrl>https://www.inxpact.nl</authorUrl>
<copyright>Copyright (C) 2022 Inxpact</copyright>
<description>Hof van Welbevinden template Joomla 4.0</description>
<files>
<filename>index.php</filename>
<folder>css</folder>
<folder>favicon</folder>
<folder>html</folder>
<folder>img</folder>
<folder>js</folder>
<folder>less</folder>
</files>
<positions>
<position>hoofdmenu</position>
</positions>
<config>
</config>
</extension>
After I updated to J4.1 I changed it to:
<?xml version="1.0" encoding="utf-8"?>
<extension type="template" client="site">
<name>Hof van Welbevinden</name>
<version>1.0</version>
<creationDate>Februari 2022</creationDate>
<author>Inxpact</author>
<authorEmail>info@inxpact.nl</authorEmail>
<authorUrl>https://www.inxpact.nl</authorUrl>
<copyright>Copyright (C) 2022 Inxpact</copyright>
<description>Hof van Welbevinden template Joomla 4.1</description>
<inheritable>1</inheritable>
<files>
<folder>html</folder>
<folder>include</folder>
<filename>index.php</filename>
<filename>joomla.asset.json</filename>
<filename>templateDetails.xml</filename>
</files>
<media destination="templates/site/inxpact" folder="media">
<folder>css</folder>
<folder>favicon</folder>
<folder>images</folder>
<folder>js</folder>
<folder>less</folder>
</media>
<positions>
<position>hoofdmenu</position>
</positions>
<config>
</config>
</extension>
I chenged that now (updated the CMS). I also noticed I also had the wrong media folder (...). After changing the XML (name and media folder) and uploading it this the template image was still not showing in the backend.
But after uninstalling and reinstalling the template it worked! So no bug but my mistake.
Thanks very much for looking into this and helpng me out!
You're welcome
The template name also can not contain capital letters... Or maybe it can but the also the folder name needs to have the same capitals? Not sure how that would work out on different server. Anyway, best to just use all lowercase and no spaces.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-02-19 10:36:07 |
Closed_By | ⇒ | jjnxpct |
@jjnxpct an update here, you can have the name field to whatever you want if you also specify a field named element with the template's folder name, something like (assuming that whatever
is the template folder:
<name>It doesnt matter</name>
<element>whatever</element>
OK, thanks. Good to know!
Status | Closed | ⇒ | New |
Closed_Date | 2022-02-19 10:36:07 | ⇒ | |
Closed_By | jjnxpct | ⇒ |
@dgrammatiko using the (with wihtespaces) and the extra tag (template and media folder) causes the template images not to show in the backend. I don't know if this is a bug then? I will this and just use the folder as template name in the XML.
Confirmed
@dgrammatiko using the (with wihtespaces) and the extra tag (template and media folder) causes the template images not to show in the backend. I don't know if this is a bug then? I will this and just use the folder as template name in the XML.
Unfortunately the current code depends on the old convention (name is the folder name of the template)
@dgrammatiko i've found the reason. The problem happens only on case sensitive Linux because the <name>Templatename</name>
starts with uppercase.
The public function thumb($template, $clientId = 0)
should do
$template->name = strtolower($template->name);
otherwise the path will be wrong and the preview won't be loaded. Definitely a Joomla bug to be fixed.
I can confirm this issue. On a Linux server, the images as well as the media folder within the file manager don't show up. The files itself are all there but are not recognised due to the "name" being uppercase but the folder is lowercase.
On Windows, everything works fine.
Changing the template name to lowercase fixes the issue as well.
But I agree a strtolower
would make sense anyway.
Revisiting this as it popup up elsewhere, the proposed solution with the strtolower()
although will probably solve the problem it's not the complete solution. A complete solution is to look for a field named element
(the folder name) and leave the name to be used for whatever string the devs are intended to name their template (folder name !== template name). As a fallback for existing templates without the element field fallback to using the name wrapped in a strtolower
.
My 2c
That would be a rather big change if you want to go that route. As you would have to adjust eg the install routines to take the element instead of name with a fall back to name as well there. And probably many other places as well.
I don't think we want to go that way when a simple strtolower works as well.
Keep in mind that the name
is a translateable property. If the name of the template is different to the folder, just use a language string and name it whatever you want.
@Bakual maybe I didn't explain this well enough. Let me retry, but first an image of the current #__extensions
table:
The column name should be any string that is translatable and only defines the NAME of the template. The name DOES NOT have to be the same as the folder name of the template. The folder name of the template should be the same as the value in the element
column. Right now all these values need to be the same!!!
Also from a consistency point of view the value for the name should be tmpl_cassiopeia
to match the mod_
, plg_
, com_
and lib_
which are also a prerequisite for publishing anything to the JED.
All I'm suggesting here is support the element value and fall back to the name value (with or without any more hacks). At some point (v5 or whatever) these should be hard requirements and both element and name fields should exist
That is because in the install manifest, we only define the name
, not the element
. The element
afaik is done automatically by Joomla during installation somewhere.
Is it possible to specify an element
in the manifest which is different from name
? I honestly never tried and don't see a reason.
As said, name
is supposed to be translated anyway, so it is no problem to have that represent the folder name as well. Why would you want to have a difference between name
and element
in the database to begin with?
As for having it prefixed with tmpl_
: That should be possible already, or not?
@jjnxpct @joeforjoomla could you please test #37256
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-03-12 21:56:53 |
Closed_By | ⇒ | richard67 |
There are two images:
The thumbnail is the smaller one, the preview the one that gets opened in the modal
Of course, "your_template" needs to match the name of your template.
The other thing to know is that in the XML you need to set
<inheritable>1</inheritable>
. This tells Joomla to look in the media folder.