此页描述了如何使用Sitecore9 (通过PostMan)检索项、(直接)子项和在Sitecore9中进行搜索。
它似乎没有说的是如何组合这些查询。
我想搜索由children指定的item的path。所以,目前,我有一个返回项目:
GET https://{{sitecorehost}}/sitecore/api/ssc/aggregate/content/Items('{{sitecorehome}}/banners-tests')?sc_apikey={{sitecore-master-apikey}}我还让它返回该项目的子项:
GET https://{{sitecorehost}}/sitecore/api/ssc/aggregate/content/Items('{{sitecorehome}}/banners-tests/Subcontent/Image and Texts')/Children?sc_apikey={{sitecore-master-apikey}}然而,因为这些孩子不是直接的孩子--他们在/Subcontent/Image and Texts是两个层次的--我不能要求他们。是的,我可以搜索它们,但是任何项目都会带着匹配的条件返回,我只想在特定的路径下搜索条目。
我想我想要的是这样的东西:
GET https://{{sitecorehost}}/sitecore/api/ssc/aggregate/content/Items?sc_apikey={{sitecore-master-apikey}}&$filter=Name eq 'banner' and Path eq 'banners-tests'也许是这样的:
GET https://{{sitecorehost}}/sitecore/api/ssc/aggregate/content/Items('{{sitecorehome}}/banners-tests')/Children?sc_apikey={{sitecore-master-apikey}}&$filter=Name eq 'banner'但这些都不管用。
发布于 2020-01-11 20:24:29
@Matt我们可以根据项目路径进行过滤。例如,将项目路径视为:
因为'/‘不是Sitecore项名称中的有效字符,并指示所需项的子元素。因此,它可以用作javascript中的筛选器。因此,我们可以分割‘图像和文本’,然后找到项目。例如,考虑一个结果数组,让我们假设对象具有一个项集合,每个项的项路径由path表示(假设,这也可以是其他一些属性)属性。
let items = [{
Path: 'sitecore/content/home/tenant1/Subcontent/Image and Texts/neededitem',
anotherProperty: 'text-val1'
}, {
Path: 'sitecore/content/home/tenant1/Subcontent/Image and Texts/item1/neededitem/notneededitem',
anotherProperty: 'text-val2'
}];
const results = items.filter(item => {
const splittedPath = item.Path.split('Image and Texts');
if (splittedPath[1].split("/").length <= 2) {
return item;
}
});
console.log(results);
如果您的SSC控制器(C#)是自定义控制器,并且能够访问Sitecore上下文对象或Sitecore,那么Item类的GetChildren()方法将只带来第一级的子级。我希望这能帮到你。
https://stackoverflow.com/questions/59180740
复制相似问题