I have developed a simple module and tried to use joomla.asset.json file in this module to register assets. The problem is that the assets written in this file are not registered and I have to use the PHP code to register the use of the assets.
I have used this method many times in Joomla and it has worked. But this is not the case in the Joomla module.
joomla.asset.json content:
Code: Select all
{
"$schema": "https://developer.joomla.org/schemas/json-schema/web_assets.json",
"name": "mod_instaads",
"version": "4.2.3",
"description": "This file contains details of the assets used by module instaads.",
"license": "GPL-2.0-or-later",
"assets": [
{
"name": "instaads",
"type": "style",
"uri": "mod_instaads/instaads.css"
},
{
"name": "fontawesom",
"type": "style",
"uri": "system/joomla-fontawesome.min.css"
},
{
"name": "all-instaads",
"type": "preset",
"description": "description",
"dependencies": [
"instaads#style",
"fontawesom#style"
]
}
]
}
Code: Select all
use Joomla\CMS\Factory;
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->usePreset('all-instaads');
Code: Select all
use Joomla\CMS\Factory;
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->registerAndUseStyle('instaads', 'mod_instaads/instaads.css');
thanks for your help.