我有一个自定义媒体项模板,允许用户将类别过滤器添加到上传的文件中。媒体项目保存在媒体库中。过滤器将从内容树中相关站点的主页项下的文件夹中选择。它们是使用树列表控件选择的。我们有多个站点,每个站点都有自己的主页项目和过滤器文件夹。我需要将树列表控件的源设置为指向每个站点的相对过滤器文件夹。
如果媒体项目位于 Hoe 项目下,我可以使用这个:
query:ancestor-or-self::*[@@templatename='Home']/item[@key='filters']
但是,当然媒体项目不会找到 ancestor-or-self::*[@@templatename='Home']
因为它不在那个分支上,它是平行的。
我怀疑我们的命名标准是否足够强大,以确保任何相对路径完全基于项目名称,并且我宁愿避免必须连接媒体文件夹的名称来查找主页项目的正确名称。
有什么办法可以优雅地解决这个问题吗?
我当然可以将过滤器文件夹放在其他地方,要么在媒体库中(宁愿避免这种情况,因为它对我们的业务用户来说并不直观),要么在全局部分中(他们必须在下面找到自己的特定站点文件夹 -或向内容树添加另一个安全配置)。
I have a custom media item template that allows users to add category filters to the uploaded file. The media item is kept in the media library. The filters are to be selected from a folder underneath the Home item of relevant site in the content tree. They are selected using a treelist control. We have multiple sites, each will have their own Home item and filter folder. I need to set the source of the treelist control to point to the relative filter folder for each site.
If the media item were under the Hoe item I could use this:
query:ancestor-or-self::*[@@templatename='Home']/item[@key='filters']
But of course the media item won't find ancestor-or-self::*[@@templatename='Home']
as it isn't on that branch, it's parallel.
I doubt our naming standard will be robust enough to ensure any relative path based entirely on item names, and I'd rather avoid having to concatenate a name of a media folder to find the correct name of the Home item.
Is there any way of solving this elegantly?
I could of course put the filters folder elsewhere, either in the Media library (would rather avoid this as it will not be intuitive to our business users) or in a global section (where they would have to find their own specific site folder below - or add another security configuration to the content tree).
发布评论
评论(2)
getLookupSourceItems 管道将允许您将自定义标记/语法添加到 Source 字段,例如查找正确站点的主页项目。
http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2011/05/Reference-the-Context-Item-and-System-Date- in-the-Source-Property-of-Sitecore-ASPNET-CMS-Fields.aspx
但是,据我所知,TreeList 不使用此管道。因此,另一个选择可能是创建自定义 TeeList 字段类型。
http://www.cmssource.co.uk/blog/custom-tree-list
The getLookupSourceItems pipeline would allow you to add custom tokens/syntax to the Source field, e.g. a lookup to the correct site's home item.
http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2011/05/Reference-the-Context-Item-and-System-Date-in-the-Source-Property-of-Sitecore-ASPNET-CMS-Fields.aspx
However from what I can gather, TreeList does not use this pipeline. Thus another option might be to create a custom TeeList field type.
http://www.cmssource.co.uk/blog/custom-tree-list
回答我自己的问题:
如果不采用某种形式的命名标准,这是不可能做到的。如果媒体库内的分支镜像内容树内的分支(站点1、站点2、站点3等),则命名标准可以强制媒体库分支和内容树分支之间的正确关系。如果没有这样的命名标准和分支镜像,那么在不添加某种配置项来包含引用的情况下,就无法将媒体文件夹与特定站点连接起来。
Answering my own question:
This isn't possible to do without employing some form of naming standard. If the branches within the media library mirror the branches within the content tree (Site1, Site2, Site3 etc) then a naming standard could enforce the correct relation between a media library branch and a content tree branch. If no such naming standard and branch mirroring is in place then there is no way of connecting a media folder with a specific site without adding a configuration item of some sort to contain the reference.