我可以在Sitecore的XSLT访问哪些内在的参数?我应该如何揭露全局设置,我需要什么?全局、参数、Sitecore、XSLT

2023-09-03 07:22:11 作者:诺言敌不过时间

是否有内在参数提供给Sitecore的XSLT文件列表?我环顾四周,但没有看到任何看起来像一个完整列表,至少在比较数据的排序.NET组件可以直接访问。使用XSLT在Sitecore的盒子似乎有点限于相对于它可以很容易地在比较.NET presentation组件访问的内容

Is there a list of inbuilt parameters available to Sitecore XSLTs? I've looked around but haven't seen anything that looks like a full list, at least not in comparison to the sort of data a .NET component can access directly. Using XSLT out of the box in Sitecore seems a little limited in respect to the data it can easily access in comparison to .NET presentation components.

我在能够访问各种片与上一个实例安装运行多个网站和语言的信息特别感兴趣 - 在主节点,主机名称,网站名称等,在.NET中的大多数,这似乎是可无论是通过Sitecore.Context或通过.NET服务器对象。我需要能够掌握这两个方面的具体信息,并设置在同一个解决方案,其他域/网站。

I'm specifically interested in being able to access various pieces of information relating to running multiple sites and languages on a single instance installation - the home node, host name, site name etc. In .NET most of this seems to be available either through the Sitecore.Context or through .NET server objects. I need to be able to get hold of both context specific information and settings for other domains/sites in the same solution.

例如。 mysite1.com在EN-GB和mysite2.com在DA-DK都指向只是在不同的语言相同的内容。两个域可以在理论上支持进一步的语言,其中一些可能被共享(例如,这两个站点允许FR-FR翻译)。在这种情况下,我需要知道我在哪个网站目前而言,我的语言,哪些是支持的语言。类似的信息将需要确定,例如网站特定的CSS,内容部分等。

E.g. mysite1.com in en-GB and mysite2.com in da-DK are pointing at the same content just in different languages. Both domains could theoretically support further languages, some of which might be shared (e.g. both sites allowed a fr-FR translation). In this case I need to know which site I'm in currently, which language I'm in and which languages are supported. Similar information will be needed to determine e.g. site specific CSS, content sections etc.

如果我需要公开这些全球和站点设置应该怎么做呢?我可以看到几个可能的方法,包括:

If I need to expose these global and site settings how should I go about it? I can see several possible methods, including:

在编写扩展函数在C# 在创建全局设置,模板/项目,并使用XSLT来阅读它们,并将它们转换成参数 - 在XSLT可以列入/按照要求其他X​​SLT文件导入

这样做的目的是让所有的code尽可能通用。

The aim is to keep all code as generic as possible.

是否有这样的最佳实践?什么是两种方法的缺点以上?

Is there a best practice for this? What are the drawbacks of the two methods above?

推荐答案

Sitecore的可扩展XSL辅助功能的完整列表记录在API参考帮助文件,可从的链接。

The full list of available Sitecore extensions for xsl helper functions is documented in the API reference helpfile, available from the link.

在XSL辅助功能都包含在 XslHelper

The XSL helper functions are contained in the XslHelper Class

命名空间►Sitecore.Xml.Xsl►XslHelper

Namespaces ► Sitecore.Xml.Xsl ► XslHelper

帮助文件文档是C#(其中扩展内置),但作为文档注释:

The helpfile documentation is for C# (in which the extensions are built), but as the documentation notes:

辅助功能与XSL使用   文件。在这个公共职能   类可以从一个XSL文件被称为   通过使用SC preFIX(前。   SC:FLD(...))

Helper functions for use with xsl files. The public functions in this class can be called from an xsl file by using the sc prefix (ex. sc:fld(...))