【发布时间】:2013-09-09 13:09:07
【问题描述】:
我正在尝试在 joomla 前端的新文章中添加新字段,如下所述:http://docs.joomla.org/Adding_custom_fields_to_the_article_component
但这些字段未显示在表单上。谁能解释一下原因?
以下是我在插件文件中编写的代码:
function onContentPrepareForm($form, $data)
{
if (!($form instanceof JForm))
{
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
// Add the extra fields to the form.
// need a seperate directory for the installer not to consider the XML a package when "discovering"
JForm::addFormPath(dirname(__FILE__) . '/rating');
$form->loadFile('rating', false);
return true;
}
我观察到的一件事是,在组件内部的 com_content 文件夹中,编写了固定代码,这就是为什么我的字段不可见的原因。如果我更改文件可以吗:\components\com_content\views\form\tmpl
【问题讨论】:
-
假设您没有逐字使用文档中的代码,您应该发布您的插件代码。您的插件很可能没有正确注册。安装了吗?启用?我会在插件代码中直接执行 var_dump 或 exit 语句,以确保它甚至正在运行。
-
@DavidFritsch 我添加了我的代码段,如果你能帮忙的话!
-
@DavidFritsch 我的插件已安装、启用并正在执行,我已经使用 die() 对其进行了测试。
-
是所有插件文件中的代码吗?
-
@DavidFritsch 是的,我在问题中复制的代码来自我的插件文件 rating.php