gpt4 book ai didi

javascript - 通过外部 javascript 获取 AEM 子节点

转载 作者:行者123 更新时间:2023-11-30 19:55:40 24 4
gpt4 key购买 nike

我正在创建一个 React 应用程序,它需要继承特定于 AEM CMS 中每个产品的辅助导航。

假设我们在 CMS 中有如下布局的页面:

- Product 1
-- Child Page 1A
-- Child Page 1B
-- Child Page 1C
- Product 2
-- Child Page 2A
-- Child Page 2B
-- Child Page 2C

现在,如果有人正在加载产品 1,我想在外部应用程序中查询 AEM 以获取产品 1 的子节点。

这可能吗?如果是,怎么办?我不知道是否有我可以利用的 AEM API,或者我是否可以使用 sling/selector 组合来获取子节点?任何帮助将不胜感激。

谢谢

最佳答案

您可以让页面的子节点执行具有所需深度和“json”扩展名的 GET 请求。例如,如果你点击这个:

.../Product1.1.json

JSON 结果将是这样的:

{
"jcr:primaryType": "cq:Page",
"jcr:createdBy": "admin",
"jcr:content": {
"jcr:primaryType": "cq:PageContent",
"jcr:createdBy": "admin",
"jcr:title": "Product1",
"cq:template": "X",
"sling:resourceType": "Y",
"cq:lastModifiedBy": "admin"
},
"child-page-1A": {
"jcr:primaryType": "cq:Page",
"jcr:createdBy": "admin"
},
"child-page-1B": {
"jcr:primaryType": "cq:Page",
"jcr:createdBy": "admin"
},
"child-page-1C": {
"jcr:primaryType": "cq:Page",
"jcr:createdBy": "admin"
}
}

如果将深度从 1 增加到 X,您可以从子节点/页面获得更多信息。

Sling Default JSON Rendering

As Florian Salihovic pointed out, the Default Renders may be disabled in a Production/Publish enviroment. In this case you can implement a similar functionality with a Custom Servlet.

关于javascript - 通过外部 javascript 获取 AEM 子节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54030224/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com