【问题标题】:Link back query not working for ContentBlocksFieldPlugin链接回查询不适用于 ContentBlocksFieldPlugin
【发布时间】:2019-07-05 15:28:41
【问题描述】:

我是 hippo cms 的新手,如果我没有使用正确的术语,我深表歉意。

我已点击此链接并获得了第一个查询 cms hippo docs

我分别有 2 个文档类型 Master 和 Servant。

主doctype java和yaml文件如下

@HippoEssentialsGenerated(internalName = "website:link")
public List<HippoBean> getLink() {
    return getLinkedBeans("website:link", HippoBean.class);
}

yaml 代码

  /link:
    /cluster.options:
      base.path: /content/documents
      jcr:primaryType: frontend:pluginconfig
      last.visited.enabled: true
      nodetypes:
      - website:servant
    caption: Link
    field: link
    hint: ''
    jcr:primaryType: frontend:plugin
    plugin.class: org.hippoecm.frontend.editor.plugins.field.NodeFieldPlugin
    wicket.id: ${cluster.id}.field

  /link:
    hipposysedit:mandatory: false
    hipposysedit:multiple: true
    hipposysedit:ordered: false
    hipposysedit:path: website:link
    hipposysedit:primary: false
    hipposysedit:type: hippo:mirror
    hipposysedit:validators:
    - optional
    jcr:primaryType: hipposysedit:field

Master 已经获得了linkedbean 来链接到如上所示的servant doctype。

现在我想在仆人文档类型中显示主详细信息,所以我添加了一个如下所示的查询,它按预期工作。


public Master getParentDetails() {
    final HstRequestContext context = RequestContextProvider.get();

    try {
        HstQuery linkedBeanQuery = ContentBeanUtils.createIncomingBeansQuery(
            this.getCanonicalBean(), context.getSiteContentBaseBean(),
            "*/website:link/@hippo:docbase",
            Master.class, false);
        linkedBeanQuery.setLimit(1);
        return (Master) linkedBeanQuery.execute().getHippoBeans().nextHippoBean();
    } catch (QueryException queryException) {
        log.warn("QueryException ", queryException);
    }
    return null;
}

问题是当我将 Master 中的插件类更改为 plugin.class: org.onehippo.forge.contentblocks.ContentBlocksFieldPlugin 并添加复合列表 compoundList: website:junior 时,事情停止工作并给出错误。

请注意,现在上面显示的 getlink() 方法和 link yaml 代码已移至名为 Junior 的新化合物中。

Master 只是为了让多个组合的 Junior 使用适当的代码如下所示。


@HippoEssentialsGenerated(internalName = "website:servantlink");
public List<HippoBean> getServantlink() {
    return getLinkedBeans("website:servantlink", HippoBean.class);
}

yaml 代码


  /servantlink:
    /cluster.options:
      jcr:primaryType: frontend:pluginconfig
      nodetypes:
      - website:servant
    caption: groups
    compoundList: website:junior
    contentPickerType: links
    field: servantlink
    hint: ''
    jcr:primaryType: frontend:plugin
    plugin.class: org.onehippo.forge.contentblocks.ContentBlocksFieldPlugin
    wicket.id: ${cluster.id}.field
    wicket.skin: skin/content-blocks.css
  /servantlink:
    hipposysedit:mandatory: false
    hipposysedit:multiple: true
    hipposysedit:ordered: false
    hipposysedit:path: website:servantlink
    hipposysedit:type: hippo:compound
    hipposysedit:validators:
    - contentblocks-validator
    jcr:primaryType: hipposysedit:fiel

所以我的问题是现在应该如何查询?

任何帮助将不胜感激。提前致谢

【问题讨论】:

    标签: content-management-system hippocms


    【解决方案1】:

    看起来在新情况下,您正在创建具有链接的 website:junior 类型的化合物。所以在传入的 bean 查询中,相应地更改“*/website:link/@hippo:docbase”。

    希望对您有所帮助, 杰伦

    【讨论】:

    • 谢谢,但我的查询与您的建议相同。请检查上面
    【解决方案2】:

    终于搞定了

    主java类应该如下。请注意这里使用 getChildBeansByName 而不是 getLinkedBeans。

    @HippoEssentialsGenerated(internalName = "website:servantlink");
    public List<HippoBean> getServantlink() {
        return getChildBeansByName("website:servantlink");
    }
    

    master.yaml 中没有任何变化,一切都很好。 现在Servant java类中的查询部分应该如下。

        final HstRequestContext context = RequestContextProvider.get();
    
        try {
            HstQuery linkedBeanQuery = ContentBeanUtils.createIncomingBeansQuery(
                this.getCanonicalBean(), context.getSiteContentBaseBean(),
                "website:servantlink/website:link/@hippo:docbase",
                Master.class, false);
            linkedBeanQuery.setLimit(1);
            return (Master) linkedBeanQuery.execute().getHippoBeans().nextHippoBean();
        } catch (QueryException queryException) {
            log.warn("QueryException ", queryException);
        }
        return null;
    }
    

    最重要的部分是这个website:servantlink/website:link/@hippo:docbase

    【讨论】:

      猜你喜欢
      • 2015-02-09
      • 2020-08-18
      • 2017-06-22
      • 1970-01-01
      • 1970-01-01
      • 2017-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多