Copied to clipboard

Flag this post as spam?

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


  • MartinB 411 posts 512 karma points
    Aug 09, 2010 @ 15:15
    MartinB
    0

    images from folder 4.5 schema

    So..

    i've read the topics on here about selecting images from a folder i umbraco 4.5.1 running the new xml schema.

    I found this guide at the bottom on the following page:

    http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/xslt-examples-updated-to-new-schema

    <xsl:for-each select="umbraco.library:GetMedia($images, true())/Image">
     
     
      <xsl:variable name="picFile" select="umbracoFile"/>
      <xsl:variable name="picW" select="umbracoWidth"/>
      <xsl:variable name="picH" select="umbracoHeight"/>
     
       
       
          <img>
              <xsl:attribute name="src"><xsl:value-of select="$picFile"/></xsl:attribute>  
          </img>
       
       
       
    </xsl:for-each>

    Unfortunately it gives me an xslt error.

    So how is it done?

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Aug 09, 2010 @ 15:21
    Ismail Mayat
    0

    Martin,

    What exactly is the error?  Is the error when you try to save the macro? Also can you paste your complete xslt.

    I recently had issue my code looks like

    <xsl:variable name="folderToShow" select="/macro/folderToShow"/>
    <xsl:template match="/">
     
      <xsl:variable name="folderId" select="$folderToShow/Folder/@id"/>
      <xsl:if test="$folderId!=''">
        <hr class="TitleLine"/>
        <h2><xsl:value-of select="$folderToShow/Folder/@nodeName"/></h2>
        <h3>Please click on a thumbnail to view the full size image</h3>
        <div class="mainImageContainer">
          <xsl:apply-templates select="umbraco.library:GetMedia($folderId, true())//Image"/>
        </div>
        
      </xsl:if>
    </xsl:template>

     

    This works.

    Regards

    Ismail

  • MartinB 411 posts 512 karma points
    Aug 09, 2010 @ 15:34
    MartinB
    0

    Hi Ismail

    The whole xslt looks like this:

    <?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"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


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

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <xsl:for-each select="umbraco.library:GetMedia($images, true())/Image">


    <xsl:variable name="picFile" select="umbracoFile"/>
    <xsl:variable name="picW" select="umbracoWidth"/>
    <xsl:variable name="picH" select="umbracoHeight"/>



    <img>
    <xsl:attribute name="src"><xsl:value-of select="$picFile"/></xsl:attribute>
    </img>



    </xsl:for-each>


    </xsl:template>

    </xsl:stylesheet>
  • MartinB 411 posts 512 karma points
    Aug 09, 2010 @ 15:35
    MartinB
    0

    The error is: Error reading XSLT file: \xslt\FrontpageBanner.xslt

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Aug 09, 2010 @ 15:47
    Ismail Mayat
    0

    Martin,

    Does the xslt save or is the error on front end? If its only on front end can you tag the page with querystring param ?umbDebugShowTrace=true then paste the error at from the trace it will give a bit more meaning.

    Also 2 more things

    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/bannerImage, 0)" />
    shouldnt that be
    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/bannerImage, true())" />


    also

    <xsl:for-each select="umbraco.library:GetMedia($bannerImage, true())/Image">  

    should be

    <xsl:for-each select="umbraco.library:GetMedia($media, true())/Image">

     

    Regards

    Ismail

  • MartinB 411 posts 512 karma points
    Aug 09, 2010 @ 15:56
    MartinB
    0

    Hi Ismail

    Thanks for your reply. Here's my current xslt:

    <?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"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


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

    <xsl:param name="currentPage"/>

    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/bannerImage, true())

    <xsl:template match="/">

    <xsl:for-each select="umbraco.library:GetMedia($media, true())/Image">


    <xsl:variable name="picFile" select="umbracoFile"/>
    <xsl:variable name="picW" select="umbracoWidth"/>
    <xsl:variable name="picH" select="umbracoHeight"/>



    <img>
    <xsl:attribute name="src"><xsl:value-of select="$picFile"/></xsl:attribute>
    </img>



    </xsl:for-each>


    </xsl:template>

    </xsl:stylesheet>

    And here's the trace error:

    Error loading XSLT FrontpageBanner.xslt
    XSLT-kompileringsfejl.
      ved System.Xml.Xsl.Xslt.XsltLoader.LoadStylesheet(XmlReader reader, Boolean include)
      ved System.Xml.Xsl.Xslt.XsltLoader.Load(Compiler compiler, Object stylesheet, XmlResolver xmlResolver)
      ved System.Xml.Xsl.Xslt.Compiler.Compile(Object stylesheet, XmlResolver xmlResolver, QilExpression& qil)
      ved System.Xml.Xsl.XslCompiledTransform.CompileXsltToQil(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
      ved System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
      ved System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
      ved umbraco.macro.CreateXsltTransform(XmlTextReader xslReader, Boolean debugMode)
      ved umbraco.macro.getXslt(String XsltFile)
      ved umbraco.macro.loadMacroXSLT(macro macro, Hashtable attributes, Hashtable pageElements)
  • MartinB 411 posts 512 karma points
    Aug 09, 2010 @ 15:57
    MartinB
    0

    Front end error

     

    *edit* i think i was too slow to remove the first code i pasted. The property i use a mediaPicker on to select the folder is called bannerImage, not "media".

    Sorry

  • MartinB 411 posts 512 karma points
    Aug 09, 2010 @ 16:10
    MartinB
    0

    Ok, i already got confused now, lol :-)

    All i want to know is how i get the images in a folder through the mediaPicker with 4.5 schema with the propertyAlias being "bannerImage"

    All help is much appreciated.

  • bob baty-barr 1180 posts 1294 karma points MVP
    Aug 09, 2010 @ 16:31
    bob baty-barr
    1

    i think primarily your issue is what you are setting $media equal to....

    <xsl:variable name="media" select="$currentPage/bannerImage"/>

    should do the trick, right? you are just getting the MediaID to then use for your getMedia() for-each loop below.

  • MartinB 411 posts 512 karma points
    Aug 09, 2010 @ 16:41
    MartinB
    0

    Hi Bob

    Heading home now. Will try it out tonight. I'm such a geezer when it comes to xslt so i'm quite sure it's some little mistake that ruins it all for me :(

  • MartinB 411 posts 512 karma points
    Aug 10, 2010 @ 11:50
    MartinB
    0

    Hi Bob

    You're sort of the answer to all my trouble.

    1. I suck at xslt

    2. You're suggestion got me hunting and i ended with the following, with the help from another thread also:

    <?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"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


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

    <xsl:param name="currentPage"/>

    <xsl:variable name="media" select="$currentPage/bannerImage" />

    <xsl:template match="/">

    <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($media, true())"/>
    <xsl:for-each select="$mediaItems/Image">
    <xsl:variable name="picFile" select="umbracoFile"/>
    <xsl:variable name="picW" select="umbracoWidth"/>
    <xsl:variable name="picH" select="umbracoHeight"/>
    <img>
    <xsl:attribute name="src"><xsl:value-of select="$picFile"/></xsl:attribute>
    </img>
    </xsl:for-each>

    </xsl:template>

    </xsl:stylesheet>

Please Sign in or register to post replies

Write your reply to:

Draft