0

I have a component which also contains a module as part of the component. In the component manifest I have, within the media element, a file joomla.asset.json which contains my preset styles etc. In my module manifest I have a media element containing folders for css and js files which has the destination of mod_mymodule but rather than duplicate the styles in the module I wanted to utilise the preset from the component. So within the module manifest I have 2 media elements, one for the standard destination of mod_mymodule and a second for destination of com_mycomponent pointing to joomla.asset.json of the component. It appears to work satisfactorily, however, is this a wise thing to do? Any and all guidance appreciated.

<media destination="mod_mymodule" folder="media">
    <folder>css</folder>
    <folder>js</folder>
</media>
<media destination="com_mycomponent" folder="media">
    <file>joomla.asset.json</file>
</media>
7
  • Is the content on the joomla.asset.json included in your installation .zip for the module that same file or a copy of the joomla.asset.json ? I would think overwriting the joomla.asset.json file of one extension during the installation of another extension could lead to confusion for anyone else looking at com_mycomponent and seeing a mismatch in the joomla.asset.json files if they aren't aware of what is going on.
    – Irata
    Commented Nov 15, 2023 at 6:39
  • I did try once, and I can't remember whether I got it working, to load the assets from one extension so that I could refer to and use them in my other extension which I think sounds similar to what your are trying to do. From memory I got to the point where I had to load the whole component or at least load the JS/CSS assets manually before I could use them.
    – Irata
    Commented Nov 15, 2023 at 6:44
  • I only have one joomla.asset.json file which is installed via the component. My install zip file contains the component and the module but I didn't want to repeat the asset file in the module when I could utilise the components assets. So yes it sounds like we are doing the same thing and it appears that having the 2 media elements within the module manifest works fine but I was concerned that it may not be wise to do it this way and suffer with the duplication. Commented Nov 16, 2023 at 7:08
  • What is even the point of including the JSON in module manifest? The same file will just be written twice during package installation (assuming the JSON is also included in the component manifest).
    – Sharky
    Commented Nov 21, 2023 at 7:37
  • @Sharky - I'm not duplicating the json file in the module, just using the one in the component. I only have one json file - in the component and I'm wanting to point to this json file in the module manifest. Commented Nov 22, 2023 at 22:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.