Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Snelbert 13 posts 33 karma points
    Jan 27, 2011 @ 20:58
    Snelbert
    0

    Empty result in first line when listing media

    Matt Brailsford kindly helped me out creating a list of documents stored a media folder.  The only issue is that the first link to an image is always blank, every other link on every page works fine.

    Can anyone see what I have done that will be causing this?

    Thanks in advance.

    Example:

    <li><a href="" target="_blank"></a></li>
    <li><a href="/media/18158/br-domestic (cont).pdf" target="_blank">BR-Domestic (Continued)</a></li>
    <li><a href="/media/18161/br-domestic.pdf" target="_blank">BR-Domestic</a></li>
    <li><a href="/media/18164/br-nd.pdf" target="_blank">BR-ND</a></li>
    <li><a href="/media/18167/cawr.pdf" target="_blank">CAWR</a></li>
    <li><a href="/media/18170/cdmr.pdf" target="_blank">CDMR</a></li>



    <xsl:variable name="documents" select="umbraco.library:GetMedia('1424', 'true')"/>
      
      <xsl:template match="/">
        <xsl:variable name="recordsPerPage" select="7"/>
        <xsl:variable name="pageNumber">
          <xsl:choose>
            <xsl:when test="umbraco.library:RequestQueryString('page')
    &lt;= 1 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="count($documents/*)"/>
        <xsl:if test="$numberOfRecords > 0">
          <ul class="tecdoc">
            <xsl:for-each select="$documents/*">
              <xsl:if test="position()
    &gt; $recordsPerPage * number($pageNumber - 1) and position()
    &lt;= number($recordsPerPage * number($pageNumber - 1) +
    $recordsPerPage )"
    >
                <li>
                  <a href="{./umbracoFile}" target="_blank">
                    <xsl:value-of select="./@nodeName" />
                  </a>
                </li>
              </xsl:if>
            </xsl:for-each>
          </ul>
        </xsl:if>
     <div class="pagination">
        <xsl:if test="$pageNumber &gt; 1">
          <a href="{umbraco.library:NiceUrl($currentPage/@id)}?page={$pageNumber - 1}">previous</a>
        </xsl:if>
     
        <xsl:call-template name="for.loop">
          <xsl:with-param name="i">1</xsl:with-param>
          <xsl:with-param name="page" select="$pageNumber"></xsl:with-param>
          <xsl:with-param name="count" select="ceiling($numberOfRecords div $recordsPerPage)"></xsl:with-param>
        </xsl:call-template>
     
        <xsl:if test="(($pageNumber) * $recordsPerPage) &lt; ($numberOfRecords)">
          <a href="{umbraco.library:NiceUrl($currentPage/@id)}?page={$pageNumber + 1}">next</a>
        </xsl:if>
        </div>
     
      </xsl:template>
      
      <xsl:template name="for.loop">
        <xsl:param name="i"/>
        <xsl:param name="count"/>
        <xsl:param name="page"/>
        <xsl:if test="$i &lt;= $count">
          <xsl:if test="$page != $i">
            <a href="{umbraco.library:NiceUrl($currentPage/@id)}?page={$i}" class="pageactive">
              <xsl:value-of select="$i" />
            </a>
          </xsl:if>
          <xsl:if test="$page = $i">
            <xsl:value-of select="$i" />
          </xsl:if>
        </xsl:if>
        <xsl:if test="$i &lt;= $count">
          <xsl:call-template name="for.loop">
            <xsl:with-param name="i">
              <xsl:value-of select="$i + 1"/>
            </xsl:with-param>
            <xsl:with-param name="count">
              <xsl:value-of select="$count"/>
            </xsl:with-param>
            <xsl:with-param name="page">
              <xsl:value-of select="$page"/>
            </xsl:with-param>
          </xsl:call-template>
        </xsl:if>
  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jan 28, 2011 @ 10:07
    Sebastiaan Janssen
    0

    Try to have a look at the list of documents to see what is going on:

    <textarea>
      <xsl:copy-of select="$documents/*" />
    </textarea>
Please Sign in or register to post replies

Write your reply to:

Draft