[英]How to show custom error while installing a Joomla! 1.6 - 1.7 component?
I am writing an install script for a Joomla! 我正在为Joomla编写安装脚本! 1.7 component.
1.7组件。 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? 如何修改脚本的
install()
部分,以便在出现故障时,我可以向用户显示格式错误的HTML错误?
Currently, I only return false
from the install()
routine, which results in a cryptic error message: 目前,我只从
install()
例程返回false
,这会产生一个神秘的错误消息:
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. 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;
}
}
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;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.