freemarker - Crafter CMS:从不同的页面/内容类型检索数据
问题描述
是否可以从单独的页面检索数据?我只知道如何contentModel.VARIABLENAME
在我的 ftl 模板中使用。
例如,我目前在Page A但我要显示的数据来自Page B。
解决方案
您可以使用siteItemService
:
<#assign pageB = siteItemService.getSiteItem("/site/website/path/to/pageB/index.xml") />
您只需要替换path/to/pageB
侧边栏中所示的页面路径。返回的对象与 的类型完全相同contentModel
,因此您可以这样做siteItemService.VARIABLENAME
推荐阅读
- laravel - 唯一设备标识符 - Laravel
- powerbi - 如何连接 DAX 中另一个表的多行?
- excel - 返回带有地址的单元格值
- angular - Redux DevTools 导致 RxJS 的 switchMap 行为不同。为什么?
- jquery - 如何在 $('#id option:eq(VARIABLE)') 中使用变量?
- c# - NLog:缩进消息
- java - 如何手动读取保存在内部存储中的 Config.property 文件
- php - 在自定义 wp-query 中创建后置过滤器
- android - 从 EditText 中删除 maxLength 集
- javascript - ESLint 不会从 npm 命令抛出任何错误