2013-04-25 46 views
0

例如,我可以访问在Sitecore中创建的配置文件,并且可以获取它的名称。Sitecore:无法获取多列表项目中的所有值

(Sitecore的)设置>档案> UserTypes>娱乐执行> AR执行

<xsl:variable name="ARExec" select="$UserTypes/item[3]/item[1]"/> 

上面的代码将打印出AR执行

现在AR执行的内部我有一个多名单命名相关类型类型,里面是:

  • 音乐
  • 喜剧
  • 电视

我一直努力遵循这里的例子: http://sdn.sitecore.net/Articles/XSL/Accessing%20Field%20Values/Multilist.aspx

但是我无法重现的结果,我希望能够得到和列表出了所有3个名字,但它只让我抓住音乐,第一个项目。我想弄清楚如何遍历Multilist中的项目并将它们全部显示出来。

<xsl:template match="*" mode="main"> 
....  

<xsl:variable name="ARExec" select="$UserTypes/item[3]/item[1]"/> 

<lable><xsl:value-of select="sc:fld('Related Genre Types', $ARExec)"/></lable> 

<xsl:variable name="ids" select="concat(sc:fld('Related Genre Types',$ARExec),'|')"/> 

<xsl:call-template name="PrintTitles"> 
    <xsl:with-param name="ids" select="$ids"/> 
</xsl:call-template> 

</xsl:template> 

<xsl:template name="PrintTitles"> 
    <xsl:param name="ids"/> 
    <xsl:if test="$ids"> 
    <xsl:variable name="itm_id" select="substring-before($ids, '|')"/> 
    <xsl:if test="$itm_id"> 
     <xsl:variable name="itm" select="sc:item($itm_id,.)"/> 

     <xsl:value-of select="sc:fld('Title', $itm)"/> &amp; 

    </xsl:if> 

    <xsl:call-template name="PrintTitles"> 
     <xsl:with-param name="ids" select="substring-after($ids, '|')"/> 
    </xsl:call-template> 
    </xsl:if> 
</xsl:template> 

^打印出{id号...}音乐&

Sitecore editor

我如何通过我的多重表圈抓住并打印出所有3个项目?

回答

0

我不得不为目标的多重表项目的所有者不同,我不得不使用@key那么example code工作目标是:

<xsl:variable name="ExecUser" select="$UserTypes/item[@key='entertainment executive']" /> 
1

从我的头顶,你需要像下面这样:

<xsl:variable name="item" select="$usertypes/item[3]/item[1]" /> 

<xsl:for-each select="sc:Split('related genre types', $item)> 
    <xsl:variable name="fielditem" select="sc:item(.,.)"/> 
    <sc:text field="title" select="$fielditem]/> 
</xsl:for-each> 

我道歉的格式,我我的手机上。

[编辑]
在拆分功能我们并不需要调用SC:FLD()。

+0

嗯,我得到一个“XSL文件无法处理”错误现在,我开始从头开始,看看我是否可以重做这个,谢谢花点时间看看这个! – 2013-04-25 18:46:38

+0

噢,我想我想通了,不得不使用一个键来定位'配置文件'我试图获得多元列表: 2013-04-25 20:44:46

+1

我知道你已经知道了 - 尽管我确实修复了XSLT代码。最后一件事:如果您遇到错误“Xsl文件无法处理”,您通常可以单击感叹号来显示有关错误的更多详细信息。 – Trayek 2013-04-26 08:07:41

相关问题