Copied to clipboard

Flag this post as spam?

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


  • [email protected] 12 posts 25 karma points
    Jul 18, 2009 @ 17:16
    kitmip@gmail.com
    1

    using media picker with xslt

    I need help with xslt. I am trying to use an xslt-file to display an image an my page. The Template calls a macro, that calls the xslt-file.
    The xslt loops through the content in the node and displays it on the page. I can get text with no problems, but the images are not working.

    My xsl for the image is like this:

    <div id="ForsideBilledBoks">
        <xsl:value-of select="data [@alias = 'billedvælger']"/>
    </div>

    This displays the node id, right where the image is supposed to be. I know this is a newbie question, but how do I get the image from the id?

    Regards

    Kim

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Jul 18, 2009 @ 17:25
    Sebastiaan Janssen
    1

    Try this:

    <xsl:value-of select="umbraco.library:GetMedia($currentPage/data [@alias='billedvælger'],'false')/data [@alias='umbracoFile']" />                  

     

  • [email protected] 12 posts 25 karma points
    Jul 18, 2009 @ 20:15
    kitmip@gmail.com
    0

    thank you for the quick reply. This results in this error:

    (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
    ved Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    ved Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    ved System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
    ved System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter)
    ved System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)
    ved System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, TextWriter results)
    ved System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
    ved umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

    Any ideas, why this is so?

    Kim

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Jul 18, 2009 @ 20:49
    Peter Dijksterhuis
    1

    Try this:

    <xsl:if test="$currentPage/data [@alias = 'billedvælger'] != ''">
    <xsl:value-of select="umbraco.library:GetMedia($currentPage/data [@alias='billedvælger'],'false')/data [@alias='umbracoFile']" />
    </xsl:if>
    It throws the error because on saving the xslt, it performs some checks. It does not have a value for the property, so the GetMedia throws an error.
    By placing an if-statement, it only performs GetMedia when there actually IS a value (which would always be when you browse the site at the front-end)
    HTH,
    Peter

  • [email protected] 12 posts 25 karma points
    Jul 18, 2009 @ 21:38
    kitmip@gmail.com
    0

    Thank you again. This time no error when trying to save, but it still doesn't work though. I am thinking I havent been precise enough in my description. I have a node e.g. front page, that I want to display underlying nodes, without showing them in navigation. This way the underlying nodes becomes sections of the front page.

    like this:

    -frontpage
        -sektion
        -sektion
        -sektion

     

    The front page calls the macro, that calls the xslt-file. The xslt-file looks at the underlying pages and displays the data from each node.

    The xslt is derived from one of the standard navigational ones. The xslt is below.

    The net result is that the closing div for ForsideBilledBoks (frontpagepicturebox) disappears in output. The text parts are there, but the missing div screws up the layout. Also the image is not displayed. Is this because the mediapicker is actually a part of the subnode and not the calling node?

    <?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="/">
    <!-- The fun starts here -->
    <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '-1']">
        <!-- PRE: value must be -1, also hides node from navigation-->  
       <div class="forsidesektion">
        <div id="ForsideBilledBoks">
         <xsl:if test="$currentPage/data [@alias = 'billedvælger'] != ''">
         <xsl:value-of select="umbraco.library:GetMedia($currentPage/data [@alias='billedvælger'],'false')/data [@alias='umbracoFile']" />
         </xsl:if>
        </div>
        <div class="overskrift">
         <xsl:value-of select="data [@alias = 'overskrift']"/>
        </div>
        <xsl:value-of select="data [@alias = 'Tekst Indhold']" disable-output-escaping="yes"/>   
           
        <hr />
       </div>
     
    </xsl:for-each>

    </xsl:template>
    </xsl:stylesheet>

       Here's the template for the calling node:

    <%@ Master Language="C#" MasterPageFile="/masterpages/Master.master" AutoEventWireup="true" %>
    <asp:Content ContentPlaceHolderId="MasterContentPlaceHolder" runat="server">
     <!-- Insert "MasterContentPlaceHolder" markup here -->
     <div id="content" class="forside">
               <img src="media/dummyFlash.jpg" height="353px" width="587px" alt="dummyFlash"/>
               <umbraco:Macro Alias="XSLTViseSektioner" runat="server"></umbraco:Macro>
     </div>
    </asp:Content>

     

    The dummyflash is not important now. One step at the time.

    The content is from the subnode like this:

    Tab: sektionsindhold

    • Edit "billedvælger"

      Name
      Alias
      Type
      Tab
      Mandatory
      Description
      -
    • Edit "Overskrift"

      Name
      Alias
      Type
      Tab
      Mandatory
      Description
      -
    • Edit "TekstIndhold"

      Name
      Alias
      Type
      Tab
      Mandatory
      Description
      -

     

    Tab: Generic Properties

    • Edit "Skjult side"

      Name
      Alias
      Type
      Tab
      Mandatory
      Description
      -

    And finally. The important pant of the rendered layout is her:

    <div id="content" class="forside"> 
               <img src="media/dummyFlash.jpg" height="353px" width="587px" alt="dummyFlash"/>
               
    <div class="forsidesektion">
     <div id="ForsideBilledBoks" />
      <div class="overskrift">Råd til byggeri</div>
       <p>Dette er en sektion.</p>   
      <hr />
     </div>
     
     <div class="forsidesektion"><div id="ForsideBilledBoks" />
      <div class="overskrift">Nyhed</div>
      <p>Dette er en sektion</p>
      <p>&nbsp;<a href="/">- Læs mere................. &gt;</a></p>
      <hr />
     </div>
     
     <div class="forsidesektion">
      <div id="ForsideBilledBoks" />
      <div class="overskrift">Brochure</div>
      <p>Dette er en sektion</p>

      <hr />
     </div>
     </div>

     If you have read this far - thank you

    Kim

  • [email protected] 12 posts 25 karma points
    Jul 18, 2009 @ 21:42
    kitmip@gmail.com
    0

    Ahh - the documenttype parts didnt make it in the post. Here goes in plain text:


    Tab: sektionsindhold

      billedvælger (billedvælger), Type: Media Picker
      Edit "billedvælger"

      Overskrift (overskrift), Type: Textstring
      Edit "Overskrift"

      Edit "TekstIndhold"

    Tab: Generic Properties

      Skjult side (umbracoNaviHide), Type: True/false
      Edit "Skjult side"

    Kim

  • [email protected] 12 posts 25 karma points
    Jul 18, 2009 @ 22:11
    kitmip@gmail.com
    0

    Hi again

    Have solved the part with the missing closing div tag, but still havent got the image.

    Moved the beginning and closing div inside the test, so now it doesnt get rendered, along with the image -that still isnt rendered either.

    <xsl:if test="$currentPage/node [@alias = 'billedvælger'] != ''">
    <div id="ForsideBilledBoks">
    <xsl:value-of select="umbraco.library:GetMedia($currentPage/data [@alias='billedvælger'],'false')/data [@alias='umbracoFile']" />
    </div>
    </xsl:if>
  • [email protected] 12 posts 25 karma points
    Jul 21, 2009 @ 18:02
    kitmip@gmail.com
    0

    No ideas anyone?

    Kim

  • Almir Vereget 62 posts 150 karma points
    Jul 21, 2009 @ 18:22
    Almir Vereget
    1

    If you are looping through the nodes, remove the $currentPage parameter in front.

    <xsl:if test="node [@alias = 'billedvælger'] != ''">
    <div id="ForsideBilledBoks">
    <xsl:value-of select="umbraco.library:GetMedia(data [@alias='billedvælger'],'false')/data [@alias='umbracoFile']" />
    </div>
    </xsl:if>

     

  • [email protected] 12 posts 25 karma points
    Jul 22, 2009 @ 00:36
    kitmip@gmail.com
    0

    Thank you. This pointed me in the right direction. The final solution became like this:

    <xsl:if test="./data [@alias = 'billedvælger'] != ''">
        <div id="ForsideBilledBoks">
        <img src="{umbraco.library:GetMedia(./data [@alias = 'billedvælger'],'false')/data [@alias = 'umbracoFile']}"/>
        </div>
        </xsl:if>

    I am still not sure why this solution works and everything else doesn't.

  • 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