Php 自定义组件中的joomla 3.x标记失败
运行Joomla 3.3.0-dev 我正在关注关于向第三方组件添加标记支持的信息 我已将内容类型添加到_content_types表中,并修改了我的表文件,如下所示:Php 自定义组件中的joomla 3.x标记失败,php,joomla,joomla3.0,Php,Joomla,Joomla3.0,运行Joomla 3.3.0-dev 我正在关注关于向第三方组件添加标记支持的信息 我已将内容类型添加到_content_types表中,并修改了我的表文件,如下所示: class MycomponentTableElement extends JTable { public $tagsHelper = null; // failed when protected and public public function __construct(&$_db) {
class MycomponentTableElement extends JTable
{
public $tagsHelper = null; // failed when protected and public
public function __construct(&$_db)
{
parent::__construct('#__mycomponent', 'id', $_db);
// Add Joomla tags
JObserverMapper::addObserverClassToClass('JTableObserverTags', 'MycomponentTableElement', array('typeAlias' => 'com_mycomponent.element'));
//$this->_observers = new JObserverUpdater($this); JObserverMapper::attachAllObservers($this); // failed with or without this line
}
我在编辑模板中添加了标记字段,效果很好-但当我保存对象时,出现以下错误:
Save failed with the following error: Unknown column 'tagsHelper' in 'field list'
我错过了什么?除了前端台阶,没有其他台阶了!这些都提到了。似乎我需要修改模型,但该信息不适用
谢谢这个页面需要拷贝编辑,这是真的
我还按照第页中描述的初始步骤进行操作
为扩展视图注册“内容类型”
将“观察者方法”添加到扩展表类中
将“标记字段”添加到扩展编辑表单
但要使字段标记在自定义扩展名上工作,我需要在后端的视图文件中显式设置表单字段值:
$tagsHelper = new JHelperTags;
$this->form= $this->get('Form');
$this->form->setValue('tags', null, $tagsHelper->getTagIds( $this->item->id, 'com_custom.viewname') );
通过这种方式,编辑页面上的所有内容似乎都正常工作。。当然存在更好更干净的方法,但直到文档页面不会更新,这可以帮助别人 1-将标记字段添加到xml表单文件或编辑模板文件 2-修改内容类型表文件:
function __construct(&$db)
{
parent::__construct('#__ir_products', 'id', $db);
JTableObserverTags::createObserver($this, array('typeAlias' => 'com_itemreview.product'));
}
3-修改模型文件getItem函数:
public function getItem($pk = null)
{
$item = parent::getItem($pk);
if (!empty($item->id))
{
$item->tags = new JHelperTags;
$item->tags->getTagIds($item->id, 'com_yourcomponent.yourmodel');
}
return $item;
}
也许是因为测试版?我没有看到您在该链接中发布的代码。它看起来像是SQL错误。您是否正在尝试将某些内容保存到数据库中的tagsHelper列?也许在使用Jhelpartags类时,代码中的某个地方出现了问题。@HungTran-谢谢,但这就是问题所在。Joomla的标记助手无法解析/保存标记。没有tagsHelper列,也不应该有。