Umbraco XSLT:如何读取嵌套的uComponent multinodepicker数据

时间:2012-07-16 13:29:52

标签: umbraco

我有两个嵌套的uComponent多节点树选取器。我可以正确读取第一级数据和节点详细信息,但是当我遍历第二级节点时,节点XML数据不可用。我可以正确读取URL选择器数据。有没有人解决这个问题?

这是XML:

<section id="1121" parentid="1118" level="3" writerid="0" creatorid="0" nodetype="1120" template="0" sortorder="1" createdate="2012-07-12T15:35:50" updatedate="2012-07-13T17:11:43" nodename="Our Solutions" urlname="our-solutions" writername="admin" creatorname="admin" path="-1,1068,1118,1121" isdoc="">
    <sectionlinks>
        <multinodepicker type="content">
            <nodeid>1098</nodeid>
            <nodeid>1097</nodeid>
            <nodeid>1099</nodeid>
            <nodeid>1100</nodeid>
        </multinodepicker>
    </sectionlinks>
    <morelink>
        <url-picker mode="Content">
            <new-window>False</new-window>
            <node-id>1087</node-id>
            <url>/solutions/</url>
            <link-title>More Services</link-title>
        </url-picker>
    </morelink>
    <title>Our Solutions</title>
    <bodytext>
    &lt;p&gt;Our Solutions details&lt;/p&gt;
    </bodytext>
    <summary>Our Solutions summary</summary>
    <breadcrumbtitle>our-solutions</breadcrumbtitle>
    <umbraconavihide>0</umbraconavihide>
    <sitename>
    <sitedescription>
    <homenodeid></homenodeid>
    </sitedescription>
    </sitename>
</section>

XSLT用来解析这个:

<xsl:template match="/">
  <!-- First we check that the Multi-node Tree Picker has any nodeId values -->
  <xsl:if test="$currentPage/sections/MultiNodePicker/nodeId">
    <ul>
      <!-- Loop through each of the nodeId values -->
      <xsl:for-each select="$currentPage/sections/MultiNodePicker/nodeId">
        <!-- Since we only have the nodeId value, we need to get the actual content node using umbraco.library's GetXmlNodeById method -->
        <!-- If you prefer to use pure XPath, then used this: "$currentPage/ancestor-or-self::*[@isDoc and @level = 1]/descendant-or-self::*[@isDoc and @id = current()]" -->
        <xsl:call-template name="RenderSection">
          <xsl:with-param name="parent" select="."/>
        </xsl:call-template>      
      </xsl:for-each>
    </ul>
  </xsl:if>
</xsl:template>

<xsl:template name="RenderSection">
  <xsl:param name="parent"/>
  <ul>
      <xsl:variable name="node" select="umbraco.library:GetXmlNodeById($parent)" />
      <li>
        <!-- Output the URL using umbraco.library's NiceUrl method -->
        <a href="{umbraco.library:NiceUrl($parent)}">
          <xsl:value-of select="$node/@nodeName" />
        </a>
        <p><xsl:value-of select="$node/title" /></p>
        <p><xsl:value-of select="$node/bodyText" disable-output-escaping="yes" /></p>

        <!-- First we check that the Multi-node Tree Picker has any nodeId values -->
        <xsl:if test="$node/sectionlinks/MultiNodePicker/nodeId">
          <ul>
            <!-- Loop through each of the nodeId values -->
            <xsl:for-each select="$node/sectionlinks/MultiNodePicker/nodeId">
              <xsl:variable name="childNode" select="umbraco.library:GetXmlNodeById(.)" />
              <li> 
                <a href="{umbraco.library:NiceUrl($childNode)}">
                  <xsl:value-of select="$childNode/@nodeName" />
                </a>
              </li>
            </xsl:for-each>
          </ul>
        </xsl:if>

        <a href="{umbraco.library:NiceUrl($node/moreLink/url-picker/node-id)}">
          <xsl:value-of select="$node/moreLink/url-picker/link-title" />
        </a>
      </li>
  </ul>
</xsl:template>  

网站结构:

主页

- Page1

- Page2

- 第3页

- 章节

---- SECTION1

----第2节

---- Section3中

---- Section4

主页包含由树选择器选择的部分集合。

感谢任何指示或帮助。

0 个答案:

没有答案