我正在为Joomla编写安装脚本!1.7组件。如何修改脚本的install()
部分,以便在失败的情况下向用户显示一个格式良好的HTML错误?
目前,我只从install()
例程返回false
,这会导致一条神秘的错误消息:
组件安装:自定义安装例程失败
joomla/installer/adapters/component.php
中的component.php文件有以下代码,这让我怀疑我无法更改abort()
消息。
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;
}
}
解决方案
在返回错误之前,我可以提出一个错误,它很好地显示在黄色框中。
JError::raiseNotice(1, "Error Message <html code>");
return false;
解决方案
在返回错误之前,我可以提出一个错误,它很好地显示在黄色框中。
JError::raiseNotice(1, "Error Message <html code>");
return false;