Copied to clipboard

Flag this post as spam?

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


  • Eddie Foreman 215 posts 288 karma points
    Jul 29, 2010 @ 19:42
    Eddie Foreman
    0

    Position of media item

    Hi All

    Found a but of a bug im my xslt.  I have a lsit of news pages with a summary tab, which contains some summary text and a pdf file link.

    The page summaries are listed correcty on the news landing page, but the the pdf link for the first news article is added to each news summary.  The XSLT is:

    ...
    <xsl:template match="/">
    <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <xsl:sort select="@createDate" order="descending" />
    <div class="listItem news">
    <h2><xsl:value-of select="./data [@alias = 'newsTitle']" /></h2>
    <div class="biogCopy">
    <p><xsl:value-of select="./data [@alias = 'newsText']" /></p>
    </div>
    <xsl:variable name="pos" select=" position()"></xsl:variable>
    <xsl:variable name="mediaNode" select="$currentPage/node [data[@alias = 'fileLink']][1]/data[@alias='fileLink']" />
    <xsl:if test ="$mediaNode &gt; 0">
    <xsl:variable name="mediaItem" select="Cultiv.MediaCache:GetMedia($mediaNode, 0)" />
    <xsl:if test="string($mediaItem/data [@alias = 'umbracoFile']) != ''">
    <a class="pdfLink" href="{$mediaItem/data[@alias='umbracoFile']}">
    <xsl:attribute name="title">
    <xsl:value-of select="$mediaItem/@nodeName" />
    </xsl:attribute>
    <span><xsl:value-of select="$mediaItem/@nodeName" /></span>
    <span class="size">
    <span class="pdf">
    <xsl:value-of select="$mediaItem/data[@alias='umbracoExtension']" />
    <xsl:text> | </xsl:text>
    <xsl:value-of select="$mediaItem/data[@alias='umbracoBytes']" />
    <xsl:text> kb</xsl:text>
    </span>
    </span>
    </a>
    </xsl:if>
    </xsl:if>
    </div>
    </xsl:for-each>
    </xsl:template>
    ...

    I beleive that the following line is causing the duplicate pdf links:

     <xsl:variable name="mediaNode" select="$currentPage/node [data[@alias = 'fileLink']][1]/data[@alias='fileLink']" />

    If I change 'fileLink'][1], to 'fileLink'][2] the pdf for the second news artilce is repeated.

    Any ideas

    Using Umbraco version 4.04.2

    Thanks

    Eddie

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jul 29, 2010 @ 19:56
    Tom Fulton
    0

    Hi Eddie,

    I believe you should change this line

    <xsl:variable name="mediaNode" select="$currentPage/node [data[@alias = 'fileLink']][1]/data[@alias='fileLink']" />

    to

    <xsl:variable name="mediaNode" select="./node [data[@alias = 'fileLink']]/data[@alias='fileLink']" />

     

    So that it pulls the info from the current node in the for-each loop, not the current page

    I don't think you need the [1] either so I removed it.

     

  • Eddie Foreman 215 posts 288 karma points
    Jul 29, 2010 @ 20:05
    Eddie Foreman
    0

    Hi Tom

    Thanks for the reply, try your amend, but no links where displayed at all.  However following on from your sample I manged to get it going with:

    <xsl:variable name="mediaNode" select="./data[@alias='fileLink']" />

    Eddie

Please Sign in or register to post replies

Write your reply to:

Draft