简体   繁体   中英

How to show custom error while installing a Joomla! 1.6 - 1.7 component?

I am writing an install script for a Joomla! 1.7 component. How can I modify the install() section of the script so that in case of failure, I can show the user a nicely formatted HTML error?

Currently, I only return false from the install() routine, which results in a cryptic error message:

Component Install: Custom install routine failure

The component.php file in joomla/installer/adapters/component.php has the following code, which leads me to suspect that I can't change the abort() message.

if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'install')) 
{
     if ($this->parent->manifestClass->install($this) === false) {
          // Install failed, rollback changes
          $this->parent->abort(JText::_('JLIB_INSTALLER_ABORT_COMP_INSTALL_CUSTOM_INSTALL_FAILURE'));
          return false;
     }
  }

Solution

Before returning an error, I can raise an error, that appears nicely in a yellow box.

JError::raiseNotice(1, "Error Message <html code>");
return false;

Solution

Before returning an error, I can raise an error, that appears nicely in a yellow box.

JError::raiseNotice(1, "Error Message <html code>");
return false;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM