Copied to clipboard

Flag this post as spam?

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


  • Morten Nielsen 3 posts 23 karma points
    May 05, 2010 @ 11:48
    Morten Nielsen
    0

    Simple GetMedia problem


    This works:
    <xsl:variable name="media" select="umbraco.library:GetMedia(1070, 0)/data"/>

     

    This doesn't:
    <
    xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/data [@alias = 'PageImage'], 0)/data [@alias = 'umbracoFile']" />

     

    When saving Xslt file, I get this:

    (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current)
    at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter)
    at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)
    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 mediapicker field has @alias='PageImage', and I have done this quite many times before.
    Can anybody kick my brain, just a bit.

    thanks:)

     

     

     

     

  • Kim Andersen 1447 posts 2197 karma points MVP
    May 05, 2010 @ 11:52
    Kim Andersen
    0

    HI Morten

    Try putting a <xsl:if> around your code like this:

    <xsl:if test="$currentPage/data [@alias = 'PageImage'] != ''">
    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/data [@alias = 'PageImage'], 0)/data [@alias = 'umbracoFile']" />
    </xsl:if>

    This makes sure that the PageImage-field is not empty.

    Otherwise you could also check the "Skip testing"-box at the top of the editor, and see if the code fails, or still works.

    /Kim A

  • Morten Nielsen 3 posts 23 karma points
    May 05, 2010 @ 12:00
    Morten Nielsen
    0

    Good point, it compiled now.. Thanks alot
    I didn't  expect the compiler to look for data. I mean the Xslt File, doesn't which file it is been rendered in?!

    Now I'm left wondering why there is no data in the field, when the media picker is filled, the image is OK, and all is published?

    guess I'm rusty.

  • Morten Nielsen 3 posts 23 karma points
    May 05, 2010 @ 12:02
    Morten Nielsen
    0

    OK sorry, forget the last comment, I works now. I just don't know why :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies