如何在数据源位置中使用sitecore查询? (动态数据源)
是否可以将数据源位置(而不是数据源)设置为 sitecore 查询?
我想做的是将子布局将其数据源位置设置为包含它的项目(当前项目)下的文件夹。
子布局数据源位置应指向当前项目下的文件夹。因此,我尝试将数据源位置设置为 query:./Items/*
但这不起作用。
Is it possible to set the datasource location (not the datasource) to be a sitecore query?
What I'm trying to do is to have the sublayout set its datasource location to a folder under the item containing it (current item).
The sublayout datasource location should point to a folder under the current item. So I tried setting the datasource location to query:./Items/*
but that did not work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要查询——子布局数据源位置可以简单地使用相对路径。例如
,显然,该文件夹需要已经存在。我一直想将此代码写在博客中,它可能有点过分,但我会在这里发布,因为它可能会对您有所帮助。可以将以下内容添加到
getRenderingDatasource
管道中以创建相对路径数据源位置(如果尚不存在)。将其添加到GetDatasourceLocation
处理器之前。在子布局上,您需要添加参数
contentFolderTemplate=[GUID]
来指定所创建项目的模板。You don't need the query -- the sublayout datasource location can simply use a relative path. e.g.
Obviously though, that folder needs to exist already. I've been meaning to blog this code, and it may be overkill but I'll post here since it may help you. The following can be added to the
getRenderingDatasource
pipeline to create a relative path datasource location if it doesn't exist already. Add it before theGetDatasourceLocation
processor.On the sublayout, you'll want to add a parameter
contentFolderTemplate=[GUID]
to specify the template of the item that gets created.