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

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.

| improve this answer | |
  • 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? – Farid shahidi Apr 20 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. – Thiago Guimarães Apr 20 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? – Farid shahidi Apr 22 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 – Farid shahidi Apr 22 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 May 19 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.)

| improve this answer | |
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.

| improve this answer | |

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.