0

是否有一些文档如何为category_selection内容类型编写 jexl?当前的2.0 文档在这个主题中有点薄。

我盲目地尝试:

<property name="authors" type="category_selection">
   <meta>
      <title lang="de">Autor</title>
      <title lang="en">Author</title>
   </meta>

   <params>
      <param name="item_disabled_condition" value="parent.key == 'authors'"/>
   </params>
</property>

但它甚至不会引发错误;)。

我尝试做的是,只允许选择某个子类别的孩子。

4

1 回答 1

1

您几乎正确地完成了它,唯一的问题是可用值正是 API 返回的值。在类别的情况下,parent键是指父级的 ID。而且您不会收到错误,因为您可以访问key数字上的属性,唯一的问题是它将是undefined.

因此,您可以执行以下操作:

<property name="authors" type="category_selection">
   <meta>
      <title lang="de">Autor</title>
      <title lang="en">Author</title>
   </meta>

   <params>
      <param name="item_disabled_condition" value="parent == 1"/>
   </params>
</property>

我知道这不是很好,因为您必须将数据库 ID 放入配置中,但这是我看到当前工作的唯一方法......如果parent.key应该工作,我们将不得不调整 API。

目前返回的类别 json/admin/api/categories如下所示:

{
  "name": "Cat Name", // name in the selected language
  "id": 6,
  "depth": 2, // depth in the tree
  "parent": 2, // id of the parent
  "locale": "de",
  "defaultLocale": "de",
  "lft": 5,
  "rgt": 6,
  "hasChildren": false
}
于 2020-04-28T11:23:51.913 回答