I have this code:
$asset_manager = JFactory::getApplication()->getDocument()->getAssetManager();
$direction = JFactory::getApplication()->getDocument()->getDirection();
$asset_manager->getRegistry()->addTemplateRegistryFile('atum', 1);
$asset_manager->usePreset('template.atum.' . ($direction === 'rtl' ? 'rtl' : 'ltr'));
This works fine on the admin side.
But on the frontend, it results in:
<link href="/templates/cassiopeia/css/template.css?ac...e2" rel="stylesheet"
data-asset-name="template.atum.ltr" data-asset-dependencies="fontawesome" />
So that seems to not be as it should.
Weird thing is that the path of the file is wrong, but the asset-name is right ??♂️
Am I doing something wrong? Or does Joomla have a bug here?
Labels |
Added:
No Code Attached Yet
|
yeah well, why it should work? It is asset for the backend template :)
What you got is an expected result.
The Atum css file is template.css
/templates/cassiopeia/css/template.css
If it is expected result, then why does is there a second attribute for the addTemplateRegistryFile
method to define the client?
1 = admin, 0 = frontend.
$asset_manager->getRegistry()->addTemplateRegistryFile('atum', 1);
If the Joomla asset manager is not capable of loading admin side files on the frontend (which would be really weird if that is true), then the client attribute in the addTemplateRegistryFile is useless too.
then why does is there a second attribute for the addTemplateRegistryFile method
To tell which template registry joomla.asset.json to load:
form /templates/blabla/
or from /administrator/templates/blabla/
.
A regular extensions does not have it because it is expected that all their assets is under /media/
folder.
If you replace this
to
"uri": "administrator/templates/atum/js/template.min.css",
then it will load what you want.
But there still not reason to do it. All shared assets should be under /media
folder.
Your last comment makes no sense. This concerns the Joomla core admin template. So hacking the joomla.asset.json
file is not a solution. And telling me that the assets should be under /media
folder... again... this is core files.
So in other words, there is no clean Joomla core way to load a Joomla core media file from the admin template on the frontend.
Loading assets from admin template on front end (and vice versa) does not make sense.
Editor buttons (modal popups) might want to use assets (styling, etc) that is available in the admin template, and is not in the frontend templates.
But never mind, I stopped caring and have just hardcoded the path to the files to make it load them.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-11-22 15:18:27 |
Closed_By | ⇒ | regularlabs |
I can confirm this result and as I am not using the Cassiopeia template, this is causing modal layout problems.