2

I've created a component for handling a multitude of things for my clients, but I frequently get feedback that certain sections aren't needed or that additional sections are desired. The first solution that came to mind was to strip the component down to just core functions and create separate "addon" packages for installing each extra view.

Unfortunately, I'm not quite sure what I need to search for to figure out how to start something like this. The first/only thing I did find was documentation on how to update a component, but that feels a bit janky as a solution since each addon would need a copy of the core code and might make things a bit messy down the line.

4
  • 1
    Rather than try to manage a plethora of separate "add-ons" that can be ripped off or duct taped on to your primary component. I think I would create a single "Swiss army knife" and only unfold the desired features via some sort of enable/disable menu. But look at the type of response your question is prompting to give. This question seems at risk of being closed as Too Broad or Opinion-based. I realise that you have been a member here for years, but please take our tour to refresh your understanding of what questions are best suited for this community/network. – mickmackusa Jul 14 '20 at 14:20
  • 2
    I realize the question was pretty open and vague, but like I said I'm not quite sure what to search for in my attempts to learn more on the subject. It doesn't help that a lot of the core documentation is pretty obfuscated and hard to read. I'll continue doing a bit of research for the time being, and try to narrow down the question and/or answer it myself if I find anything definitive. – Chaosxmk Jul 14 '20 at 14:33
  • 1
    What you possibly are looking to do is to 'modularise' your component and from my own research Joomla doesn't really handle adding subsets of features to a component very well so you can take the approach suggested by @mickmackusa which could see a complete but bloated code base. My approach has been to break my large component down into smaller stand alone components that manage a particular function but may share a Library of common code. Depending on how much they interact with each other if they look consistently the same the end user doesn't see how many components are in play. – Irata Jul 20 '20 at 11:50
  • I hadn't thought of using multiple components that just share a common core code, could be a useful option to look into. – Chaosxmk Aug 3 '20 at 13:05
0

So, after having done some research and testing various things, I have an answer.

I created a spin-off of my component and stripped it down to the bare minimum. Every file that would theoretically already by included in the core was removed, only the controllers/models/tables/views were kept. Ex: (items prefixed with × were deleted)

/script.php
/administrator
    /controllers
×       /controlpanel.php
        /bulletin.php
        /bulletinlist.php
×   /css
        /general.css
    /models
×       /controlpanel.php
        /bulletin.php
        /bulletinlist.php
    /tables
        /bulletin.php
    /views
×       /controlpanel
        /bulletin
        /bulletinlist
    /controller.php
    /core.php
    /model.php
    /view.php
×/languages
    /administrator
        /en-GB
            /en-GB.com_component.ini
    /site
        /en-GB
            /en-GB.com_component.ini
/site
    /controllers
        /bulletin.php
        /bulletinlist.php
    /models
        /bulletin.php
        /bulletinlist.php
    /views
        /bulletin
        /bulletinlist
    /controller.php
    /core.php
    /model.php
    /router.php
    /view.php

In the manifest file for the installation, it's important to also trim this down to the needed content, and make sure that <extension> has the attribute method="upgrade", otherwise Joomla will cancel the install due to the component already existing.

Important things to note:

  • I've tried several different attempts, not once was I able to get the install package to run the install SQL file, I assume Joomla skips this step because this is technically an upgrade. Any SQL changes will need to be done directly in a script.php.
  • Any file that already exists will be overwritten, so for things like language files, you'll need to setup a jank solution in script.php to append new JText lines to the end of the installed language file
  • In the <administration> section of the manifest file, it's better to remove any reference to <menu> or <submenu>, I've noticed that it will erase whatever menu items existed already to replace them with the structure included in the upgrade

I don't have access to Joomla 4 at the moment to test if this will work there as well, but considering the wording in the Joomla documentation I don't see why it wouldn't work.

Update: After testing some more, I've noticed that any file that is in the root of a folder (/administrator or /site) will be deleted if not referenced in the manifest file. It looks like those files will have to be included even if they aren't different from the core files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.