1

I have a content element on my Umbraco site that I want to use as a container for content from another part of my document tree.

As shown in the image below, I need to reference all child pages under the /Content/Personal Site/Blog node from within the /Content/Frontpage Tabs/Featured Pages node.

Screen capture of site hierarchy

The XSLT I've borrowed for the job works fine if I drop it on a page below the "Personal Site" node, but yields nothing from below "Frontpage Tabs". I'm guessing because the currentPage is traversing that tree and not the Personal Site one.

The XSLT looks like this:

  <xsl:param name="currentPage"/>
  <xsl:variable name="numberOfPosts" select="3"/>
  <xsl:variable name="level" select="1"/>

  <xsl:variable name="pageNumber">
    <xsl:choose>
      <xsl:when test="umbraco.library:RequestQueryString('page') &lt;= 0 or string(umbraco.library:RequestQueryString('page')) = '' or string(umbraco.library:RequestQueryString('page')) = 'NaN'">1</xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="umbraco.library:RequestQueryString('page')"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="numberOfRecords" select="3" />

  <xsl:template match="/">

    <xsl:if test="$currentPage [name() = 'umbDateFolder']">
      <h2 class="page-title">
        Monthly Archives: <xsl:value-of select="umbraco.library:FormatDateTime(concat($currentPage/../@nodeName,'-',$currentPage/@nodeName,'-11T10:24:46'),'MMMM yyyy')"/>
      </h2>
    </xsl:if>

    <xsl:for-each select="$currentPage/ancestor-or-self::umbBlog//umbBlogPost">
        <xsl:sort select="./PostDate" order="descending" />

        <xsl:if test="position() &gt; $numberOfPosts * (number($pageNumber)-1) and
        position() &lt;= number($numberOfPosts * (number($pageNumber)-1) +
        $numberOfPosts )">

          <ul>
          <xsl:call-template name="showpost">
            <xsl:with-param name="post" select="."/>
          </xsl:call-template>
          </ul>

        </xsl:if>

     </xsl:for-each>

  </xsl:template>

  <xsl:template name="showpost">
    <xsl:param name="post"/>

    <li>
      <div class="excerpt">
        <a class="header" href="{umbraco.library:NiceUrl($post/@id)}" title="{$post/@nodeName}">
          <xsl:value-of select="$post/@nodeName" />
        </a>
        <xsl:value-of select="$post/bodyText" disable-output-escaping="yes" />
      </div>
      <a class="link-button" href="{umbraco.library:NiceUrl($post/@id)}">Read more</a>
    </li>

There'll be something obvious I need to change but I'm not well-versed enough in XSLT so any assistance is hugely appreciated.

4

2 に答える 2

2

マクロで contentpicker タイプのパラメーター (たとえば、「source」という名前) を作成し、このパラメーターの値を currentPage の代わりにコンテナー ノードの ID として使用する必要があります。私はよくそのトリックを使用しますが、完全に機能し、管理者のバックオフィスでノードを変更できます。

于 2012-09-07T12:36:49.113 に答える
1

ノード「個人用サイト」になる新しい変数を作成し、すべての子を取得する必要があります。このノードを作成するには、web.config にキーを使用してその ID を追加します。

于 2012-08-21T10:17:10.543 に答える