【问题标题】:How to set the resource group in MODx plugin?如何在MODx插件中设置资源组?
【发布时间】:2015-04-16 17:11:52
【问题描述】:

我正在使用 MODx Revolution,我需要在保存时将组设置为插件中的资源。但是$modx->newObject() 不起作用,并且资源组未设置为资源。

这是我的代码:

$id = $resource->get('id');
$group = $modx->newObject('modResourceGroupResource');
$group->set('document', $id);
$group->set('document_group', 5);
$group->save();

我保存了所有数据,但资源组未设置为资源。我不明白我做错了什么。请帮帮我。

【问题讨论】:

    标签: php modx modx-revolution


    【解决方案1】:

    试试这个:

    // by id
    if (!$resource->isMember(123)) {
        $resource->joinGroup(123);
    }
    // or by name
    if (!$resource->isMember('ResourceGroupName')) {
        $resource->joinGroup('ResourceGroupName'); 
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-21
      • 1970-01-01
      相关资源
      最近更新 更多