1

I created my own component in joomla and I want to show a custom warning when my users want to auto update the component. When they try to update it joomla could not find the zip file and return a warning in this file: administrator\components\com_installer\models\update.php line:434

if (!$p_file)
{
    JError::raiseWarning('', JText::sprintf('COM_INSTALLER_PACKAGE_DOWNLOAD_FAILED', $url));

    return false;
}

How I can inject a custom message in joomla update without touching the core code.

0

3 Answers 3

0

Add <jdoc:include type="modules" /> to your index.php template file - this will show error messages - and override the core file you want.

Example: If you want to override a view of certain component, you can copy the view and paste it into templates/your-template/code/component-name/views/ (you have to create folder and subfolders). Joomla will look in the folder you created for overrided files.

More information https://docs.joomla.org/How_to_override_the_component_mvc_from_the_Joomla!_core

Tell me if it solves your problem.

7
  • I can not force my users to install any plugins to override administrator\components\com_installer\models\update.php , Am I right about it or it does not need to install override plugin? Commented Apr 20, 2020 at 9:35
  • No, you don't need it. You can override the files directly in your template by copying the file update.php located in administrator\components\com_installer\models and paste it into a folder you will create. The path should be as following: templates/your-template/code/component-name/models/. You can edit the file without having to modify the core file. Joomla will look for that folder you created and will use this overrided file. Commented Apr 20, 2020 at 12:13
  • 1
    I tested it and it is not working. Also it does not make any sense that joomla search in template/your-template/code folder, there is no reason that joomla do it, can you give me some links? Commented Apr 22, 2020 at 13:41
  • 1
    In that link you attached to your answer writes: This method only works if you install and enable the 3rd party MVC plugin joomla-override found on github - or provide your own equivalent plugin. It is fine for advanced developers - just be aware that this is not part of Joomla! Core code Commented Apr 22, 2020 at 13:43
  • 1
    Ummm, I think one of us has the wrong end of the stick. I read the original question as he was not the site owner, he was a component developer and wanted to get a message to the site owners that were using his component. So he would have no legitimate access to the template being used.
    – Arlen
    Commented May 19, 2020 at 15:21
0

Not sure you can. The update process isn't supposed to involve the component being updated until after the download succeeds; everything before that point is rightly the domain of the system, not the component. (After all, if the download fails, there's nothing for the system to read a message from, and the component being updated isn't invoked at all during the process, in no small part because PHP really doesn't like updates being made to code that's already been loaded.)

There is a long shot attempt at a solution for future customers: Maybe package your component with a plugin that runs when onInstallerAfterInstaller fires, where you can look for the the package being installed and the reason it failed. It might work, but that wouldn't help current customers and is way too complex for me to be happy with. (I like simpler approaches, I just don't see how this gets simple. If you do, have at it with my blessing.)

0

onExtensionAfterUpdate is the plugin method you're looking for. You can add this method to your existing plugin. If I understand your issue correctly, raiseWarning has already been called, so you could just simply unset it, and set your own error text.

Your Answer

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

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