【问题标题】:Contentful query content type and filter on reference (multiple)内容查询内容类型和参考过滤器(多个)
【发布时间】:2019-01-03 15:38:08
【问题描述】:

在 Contentful 中,我的内容类型为“post”。帖子可以有多个类别(另一种内容类型)。现在我正在尝试查询帖子但按类别过滤它们。我的查询看起来像这样:

https://cdn.contentful.com/spaces/$space/entries?access_token=$token&include=3&fields.categories.fields.slug=features&limit=3&skip=0&content_type=post

返回的错误: You are trying to search on a reference to an unsupported type. You can only search on references to single entries

所以基本上我只能引用 1 个类别,但我不仅在这个用例中需要很多,而且在更多方面。知道如何实现这一目标吗?

【问题讨论】:

    标签: contentful


    【解决方案1】:

    您可以翻转查询并询问链接到某个类别的条目。

    curl --include \
     --request GET \
     https://cdn.contentful.com/spaces/$SPACE_ID/environments/master/entries?access_token=$TOKEN&links_to_entry=7fYxxN67JKyUiYuE4Cq8sI&content_type=post
    

    https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/links-to-entry

    【讨论】:

    • 谢谢 周末后试试看,如果成功了会更新
    • 多个链接条目怎么样?假设我想过滤类别和标签
    • 我想你必须打两个电话。 :) 假设您的意思是您有一个内容类型 tag 和另一个 category
    • 确实,这很糟糕,但感谢您的回答!
    猜你喜欢
    • 2021-11-11
    • 2019-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-27
    相关资源
    最近更新 更多