AnswerBun.com

Is it possible to create a component "addon"?

Joomla Asked by Chaosxmk on September 5, 2021

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.

One Answer

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.

Answered by Chaosxmk on September 5, 2021

Add your own answers!

Related Questions

Getting Category’s custom fields in a blog view

1  Asked on September 5, 2021 by semaphore

   

How to post checkout data to component using Ajax?

1  Asked on September 5, 2021 by askerman

   

Display specific Joomla user groups

1  Asked on September 5, 2021 by niaziblog

   

how to get value for search in joomla module

1  Asked on September 5, 2021 by rhea-lorraine

   

Joomla installation on localhost using WAMP does not start

1  Asked on September 5, 2021 by bilal-kabeer-butt

 

Jquery script loaded on every page

1  Asked on September 5, 2021 by gag

   

category links don’t work

1  Asked on September 5, 2021 by giovanni-de-maria

         

Joomla 3.9 Child Sub Menu Not Showing

1  Asked on September 5, 2021 by ta1982

         

Trying to connect to an external ODBC data source

1  Asked on September 5, 2021 by irata

   

Can’t get a task to work from CLI

0  Asked on September 5, 2021 by tc0072

 

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP