Copied to clipboard

Flag this post as spam?

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


  • Pete Wilson 11 posts 31 karma points
    Aug 30, 2012 @ 18:31
    Pete Wilson
    0

    Error when for looping

    Hello all,

    I'm having an issue looping through a folder of nodes to display in a list of items on a page. Here's my code and explanation of what I'm trying to achieve below:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
      <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxml="urn:schemas-microsoft-com:xslt"
        xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:yorkshire.library="urn:yorkshire.library"
        exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets yorkshire.library ">

      <xsl:output method="xml" omit-xml-declaration="yes" />

      <xsl:param name="currentPage"/>

      <xsl:template match="/">

    <xsl:for-each select="$currentPage/node[@nodeName='Venue']/node[@nodeTypeAlias='Venues']">

                <div class="Venue">
                    <div class="DestinationLeft">
                        <div class="VenueName"><a href="{umbraco.library:NiceUrl(current()/@id)}"><xsl:value-of select="data [@alias = 'venueName']" disable-output-escaping="yes" /></a></div>
                        <div class="VenueAddress">
                <xsl:value-of select="data [@alias = 'Address1']" disable-output-escaping="yes" />,
                <xsl:value-of select="data [@alias = 'TownCity']" disable-output-escaping="yes" />,
                <xsl:value-of select="data [@alias = 'Postcode']" disable-output-escaping="yes" /></div>
                        <div class="VenueShortDesc"><p><xsl:value-of select="data [@alias = 'shortDesc']" disable-output-escaping="yes" /></p></div>
                    </div>
                    <div class="DestinationRight">
                    <a href="{umbraco.library:NiceUrl(current()/@id)}">
                    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/venueImage, 0)" />

                    <xsl:if test="string($media) !='' ">
                        <img src="{$media/umbracoFile}" width="278" height="215" />
                    </xsl:if>
                    </a>
                    </div>                         
                </div>
                <p><img src="/images/venues/linedash.png" width="598" height="6" alt="" /></p>
               
    </xsl:for-each>
                       
    </xsl:template>

    </xsl:stylesheet>

    So from a destination page I have a folder below it (nodeName = Venues) with items in there (nodeTypeAlias = Venue), but keep getting the old error, Error parsing XSLT file,

    Pulling my hair out for the last 3 hours, any help very gratefully received!

    Cheers
    Pete

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Aug 30, 2012 @ 20:22
    Morten Bock
    0

    Do you get the error when saving, or when it's rendered on the website?

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Aug 30, 2012 @ 21:46
    Chriztian Steinmeier
    0

    Hi Pete,

    Put ?umbDebugShowTrace=True in the URL for that page and find the (hopefully) detailed error description (should be bright red somewhere down the page).

    (Also: You say it's Venues/Venue - but your code looks for Venue/Venues - was that a typo?)

    /Chriztian

  • Pete Wilson 11 posts 31 karma points
    Aug 31, 2012 @ 09:49
    Pete Wilson
    0

    Thanks for your responses guys.

    Morten, it's happening when rendered on the website.

    Chriztian, I've tried appending ?umbDebugShowTrace=True to the url but get nothing, no sure why though? Also my typo not in the code but my explanation, so the code is referencing the correct nodes.

    Cheers

    Pete

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Sep 01, 2012 @ 16:59
    Chriztian Steinmeier
    0

    Hi Pete,

    The ?umbDebugShowTrace thing only works if the key umbracoDebugMode in web.config is true

    I'd suspect the error is caused by the call to GetMedia() - it looks as if you're using the "new Schema" syntax for that particular line:

    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/venueImage, 0)" />

    (You're also looking on $currentPage for every one of them which you probably don't mean to...)

    The rest of your code uses the old schema, so you should do this instead (and throw in a null-check too):

    <xsl:if test="normalize-space(data[@alias = 'venueImage'])">
       <xsl:variable name="media" select="umbraco.library:GetMedia(data[@alias = 'venueImage'], 0)" />
    </xsl:if>

    /Chriztian

  • Pete Wilson 11 posts 31 karma points
    Sep 05, 2012 @ 16:18
    Pete Wilson
    0

    Perfect! thanks Chriztian, that's worked! Many thanks for help and time.

    Cheers

    Pete

Please Sign in or register to post replies

Write your reply to:

Draft