我正在为我们的一位客户将 Joomla 1.5 网站迁移到 Joomla 3.8。它有一个不再受支持的外部组件,我正试图为 Joomla 3.8 工作。现在大部分都可以工作了,除了管理员中的编辑视图。
目前有 3 个字段似乎无法正常工作。
首先有名为 title 的字段和 alias 这类工作,但不再预填充它们已有的值。它们在 xml 配置文件中的格式如下:
<fieldset addfieldpath="/administrator/components/com_faqftw/models/fields"
name="essential" >
<fields name="filter">
<field name="id" type="hidden" label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC" size="10" default="0" readonly="true" class="readonly" />
<field name="title" type="text" label="COM_FAQFTW_FIELD_FAQ_NAME_LABEL"
description="COM_FAQFTW_FIELD_FAQ_NAME_DESC" class="inputbox" size="30" required="true" />
<field name="alias" type="text" label="JFIELD_ALIAS_LABEL"
description="JFIELD_ALIAS_DESC" size="30" required="false" />
其次,有一个名为“ordering”的字段,如果在 xml 中启用,则会引发 sql 错误。该字段被格式化为自定义字段,并且有自己的扩展 JFormField 的类,但禁用它并没有什么不同。那个格式是这样的:
<field name="ordering" type="Ordering" class="inputbox" label="JFIELD_ORDERING_LABEL"
description="JFIELD_ORDERING_DESC" />
抛出的 SQL 错误:
1064 You have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near 'WHERE `catid` = 0 ORDER BY ordering'
at line 3 httpdocs/libraries/joomla/database/driver/mysqli.php:650
因此,我的预感是引入了一些命名约定,并且不再允许这些字段名称。如果是这样的话,有人可以给我一些关于重命名这些文件的最面向未来的方法的指示,或者给我一些关于这些字段的文档,这些文档比 docs.joomla.org 网站上的内容更有帮助。
如果您认为我错了,我也很乐意听到,希望有一些指向正确方向的指针:)
自定义字段php文件:defined('JPATH_BASE') or die;
/**
* Supports an HTML select list of categories
*
* @package Joomla.Administrator
* @subpackage com_weblinks
* @since 1.6
*/
class JFormFieldOrdering extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'Ordering';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
* @since 1.6
*/
protected function getInput()
{
// Initialize variables.
$html = array();
$attr = '';
// Initialize some field attributes.
$attr .= $this->element['class'] ? ' class="'.(string) $this->element['class'].'"' : '';
$attr .= ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
$attr .= $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : '';
// Initialize JavaScript field attributes.
$attr .= $this->element['onchange'] ? ' onchange="'.(string) $this->element['onchange'].'"' : '';
// Get some field values from the form.
$faqId = (int) $this->form->getValue('id');
// Build the query for the ordering list.
$query = 'SELECT ordering AS value, title AS text' .
' FROM #__faqftw_faq' .
' ORDER BY ordering';
// Create a read-only list (no name) with a hidden input to store the value.
if ((string) $this->element['readonly'] == 'true') {
$html[] = JHtml::_('list.ordering', '', $query, trim($attr), $this->value, $faqId ? 0 : 1);
$html[] = '<input type="hidden" name="'.$this->name.'" value="'.$this->value.'"/>';
}
// Create a regular list.
else {
$html[] = JHtml::_('list.ordering', $this->name, $query, trim($attr), $this->value, $faqId ? 0 : 1);
}
return implode($html);
}
}