Copied to clipboard

Flag this post as spam?

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


  • Kate 267 posts 610 karma points
    Jan 19, 2011 @ 12:06
    Kate
    0

    Images from af specific folder

    Hi

    How do i get my images from a specific folder in Media?

    I have tried this:

    <xsl:variable name="mm" select="umbraco.library:GetMedia(1115, true())" />

              <ul class="foto-list">

              <xsl:for-each select="$mm/node">            

                ss

              <xsl:variable name="m" select="umbraco.library:GetMedia(./@id)"></xsl:variable>          

                <li>

                  <a href="{$m/data [@alias='umbracoFile']}" rel="lightbox" title="{$m/@nodeName}">

                    <img style="width:122px; height:89px;" src="{$m/data [@alias='umbracoFile']}" alt="" />

                  </a>

                </li>            

              </xsl:for-each>         

            </ul>

    In my html it only writes

    <ul class="foto-list" />

    My images folders id is 1115.

     

    I use umbraco v 4.5.2 and that may be my problem :-)

    Can anybody help?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 19, 2011 @ 12:35
    Matt Brailsford
    1

    Hi Kate,

    It looks like you are using the old XML scheme, you may want to try something like this:

    <xsl:variable name="mm" select="umbraco.library:GetMedia(1115, true())" />
    <ul class="foto-list">
      <xsl:for-each select="$mm/*">
        <xsl:variable name="m" select="umbraco.library:GetMedia(./@id)"></xsl:variable>
        <li> <a href="{$m/umbracoFile}" rel="lightbox" title="{$m/@nodeName}"> <img style="width:122px; height:89px;" src="{$m/umbracoFile}" alt="" /> </a> </li>
      </xsl:for-each>
    </ul>

    Matt

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 19, 2011 @ 12:37
    Dirk De Grave
    1

    Kate,

    Your iteration on the $mm/node is incorrect if you're using the v4.5 new xml schema syntax!

    Always forget the xml that's returned from the GetMedia() call, but that's a no-brainer to get the xml in a <textarea> field to check how to format the xpath to iterate the images in a specific folder.

    <xsl:variable name="mm" select="umbraco.library:GetMedia(1115, true())" />
    <textarea><xsl:value-of select="$mm" /></textarea>

    So, what's the ouput from above snippet?

     

    Cheers,

    /Dirk

     

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 19, 2011 @ 12:38
    Jan Skovgaard
    0

    Hi Kate

    The problem is probably that you're trying to match "node", which is used in the legacy scehma used by Umbraco 4.0.x and below. Since Umbraco 4.5 the XML schema has changed. So unless you have told Umbraco to use the old legacy schema in the UmbracoSettings.config file it uses the new schema.

    Therefore I suggest you try to write $mm/*[@IsDoc] in your for-each statement.

    In you variable I think it should be enough to write umbraco.library:GetMedia(@id)

    You can see some good examples on how to use the GetMedia extension in the wiki reference here: http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia

    Maybe you can just install this package to get a list of your media files? http://our.umbraco.org/projects/website-utilities/media-iterator

    Hope this helps.

    /Jan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 19, 2011 @ 12:38
    Jan Skovgaard
    0

    I'm just too slow...

    /Jan

  • Kate 267 posts 610 karma points
    Jan 19, 2011 @ 14:00
    Kate
    0

    Hi Matt

    I can´t save my file. It gives me an error.

    I think it has something to do with this line:

     <xsl:variable name="m" select="umbraco.library:GetMedia(./@id)"></xsl:variable>

    This is the error

    Error occured

    System.Xml.Xsl.XslTransformException: Extension object 'urn:umbraco.library' does not contain a matching 'GetMedia' method that has 1 parameter(s).
    at System.Xml.Xsl.Runtime.XmlExtensionFunction.Bind()
    at System.Xml.Xsl.Runtime.XmlExtensionFunctionTable.Bind(String name, String namespaceUri, Int32 numArgs, Type objectType, BindingFlags flags)
    at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
    at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver)
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 19, 2011 @ 14:01
    Matt Brailsford
    0

    Ahh, sorry, change it to:

    <xsl:variable name="m" select="umbraco.library:GetMedia(./@id, false())"></xsl:variable>

    Matt

  • Kate 267 posts 610 karma points
    Jan 19, 2011 @ 14:14
    Kate
    0

    Im sorry to bother you whit this but no it says:

    Error occured

    false

  • Kate 267 posts 610 karma points
    Jan 19, 2011 @ 14:19
    Kate
    0

    ups, forget what I wrote 2 min ago.

    I get this error:

    Error occured

    System.OverflowException: Value was either too large or too small for an Int32.
    at System.Convert.ToInt32(Double value)
    at System.Double.System.IConvertible.ToInt32(IFormatProvider provider)
    at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
    at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
    at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
    at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver)
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

    my xslt look 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:variable name="mm" select="umbraco.library:GetMedia(1115, true())" />
    <ul class="foto-list">
      <xsl:for-each select="$mm/*">
        <xsl:variable name="m" select="umbraco.library:GetMedia(./@id, false())"></xsl:variable>
        <li> <a href="{$m/umbracoFile}" rel="lightbox" title="{$m/@nodeName}"> <img style="width:122px; height:89px;" src="{$m/umbracoFile}" alt="" /> </a> </li>
      </xsl:for-each>
    </ul>


    </xsl:template>

    </xsl:stylesheet>
  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 19, 2011 @ 14:23
    Dirk De Grave
    0

    use

    <xsl:variable name="mm" select="umbraco.library:GetMedia(1115, true())" />
    <ul class="foto-list">
      <xsl:for-each select="$mm/*"> <xsl:if test="./@id">     <xsl:variable name="m" select="umbraco.library:GetMedia(./@id, false())"></xsl:variable>     <li> <a href="{$m/umbracoFile}" rel="lightbox" title="{$m/@nodeName}"> <img style="width:122px; height:89px;" src="{$m/umbracoFile}" alt="" /> </a> </li> </xsl:if>   </xsl:for-each> </ul>

    to avoid the error

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 19, 2011 @ 14:23
    Matt Brailsford
    0

    Hey Kate.

    Can you try changing true() to 1 and false() to 0 in the 2 GetMedia calls?

    Matt

  • Kate 267 posts 610 karma points
    Jan 19, 2011 @ 14:26
    Kate
    0
  • Kate 267 posts 610 karma points
    Jan 19, 2011 @ 14:34
    Kate
    0

    Hi Dirk

    Thanks it works, but I cant see the difference form what Matt did.

    Can you explain, please?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 19, 2011 @ 14:39
    Dirk De Grave
    0

    No difference in logic, but as './@id' doesn't get an actual value until runtime, the statement is considered invalid (that's just because when saving the xslt, it's also parsed). Best practise to always add an extra <xls:if> statement (Alternatively, check the 'Skip error' box)

     

    Cheers,

    /Dirk

  • Kate 267 posts 610 karma points
    Jan 19, 2011 @ 14:43
    Kate
    0

    Thanks to both of you.

    It works just like I want it :-)

Please Sign in or register to post replies

Write your reply to:

Draft