Copied to clipboard

Flag this post as spam?

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


  • Amir Khan 1287 posts 2744 karma points
    Jan 10, 2012 @ 17:29
    Amir Khan
    0

    Select just one item in template

    Hi,

    I have the code below which im using to iterate through 2 Multi-Node tree pickers and then insert both of the retrieved images into list items. I'm having trouble making so that it actually "merges" the items selected from both pickers instead of listing one then the other. Any help would be greatly appreciated!

    Thanks,

    Amir

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


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

    <xsl:param name="currentPage"/>

    <xsl:template name="backgroundImage">
    <xsl:if test="$currentPage/headerBackgroundImage/MultiNodePicker/nodeId">
       
      <!-- Loop through each of the nodeId values -->
      <xsl:for-each select="$currentPage/headerBackgroundImage/MultiNodePicker/nodeId">
      <xsl:variable name="node" select="umbraco.library:GetMedia(.,0)" />
      
      <img src="{$node/umbracoFile}" alt="[image]" height="{$node/umbracoHeight}" width="{$node/umbracoWidth}" />
      
      </xsl:for-each>
      </xsl:if>

    </xsl:template>

    <xsl:template name="factImage">
    <xsl:if test="$currentPage/headerFactPicker/MultiNodePicker/nodeId">
       
      <!-- Loop through each of the nodeId values -->
      <xsl:for-each select="$currentPage/headerFactPicker/MultiNodePicker/nodeId">
      <xsl:variable name="node" select="umbraco.library:GetMedia(.,0)" />
      
      <img src="{$node/umbracoFile}" alt="[image]" height="{$node/umbracoHeight}" width="{$node/umbracoWidth}" />
      
      </xsl:for-each>
      </xsl:if>

    </xsl:template>

    <xsl:template match="/">
    <div id="slider">
      <ul id="sliderContent">

      <li class="sliderImage">
        <xsl:call-template name="backgroundImage"/>
        <span class="left"><xsl:call-template name="factImage"/></span>
      </li>

      </ul>
    </div>
    </xsl:template>

    </xsl:stylesheet>
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 10, 2012 @ 21:31
    Jan Skovgaard
    0

    Hi Amir

    How do you want to have the images displayed? Could you ellaborate a bit more on exactly what you're trying to achieve? :)

    Not sure I understand your issue completely.

    /Jan

  • Amir Khan 1287 posts 2744 karma points
    Jan 10, 2012 @ 21:35
    Amir Khan
    0

    Hi Jan,

    So what I'd like to achieve is:

    <li>
    <img src="myimage1.jpg"/>
    <span><img src="myoverlayImage1.png"/></span>
    <li>
    <li>
    <img src="myimage2.jpg"/>
    <span><img src="myoverlayImage2.png"/></span>
    <li>

    What I'm getting is:

    <li>
    <img src="myimage1.jpg"/>
    <img src="myimage2.jpg"/>
    <span><img src="myoverlayImage1.png"/></span>
    <span><img src="myoverlayImage2.png"/></span>
    <li>

    Thanks!

    Amir

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 10, 2012 @ 21:41
    Jan Skovgaard
    0

    Hi Amir

    Ah yes, now I get it :)

    But can't you just skip the loop and then just do the following

    <xsl:variable name="backgroundImage" select="$currentPage/headerBackgroundImage/MultiNodePicker/nodeId" />
    <xsl:variable name="factImage" select="$currentPage/headerFactPicker/MultiNodePicker/nodeId" />

    This should simply just return the first node for each of your selections.

    Hope this helps.

    /Jan

  • Amir Khan 1287 posts 2744 karma points
    Jan 10, 2012 @ 21:48
    Amir Khan
    0

    So something like this Jan? I'm getting an int32 error, and an error on the front-end if I skip testing...Am I misunderstanding?

     

    <xsl:template name="backgroundImage">
    <xsl:if test="$currentPage/headerBackgroundImage/MultiNodePicker/nodeId">
       
      <!-- Loop through each of the nodeId values -->

      <xsl:variable name="backgroundImage" select="$currentPage/headerBackgroundImage/MultiNodePicker/nodeId" />
      <xsl:variable name="node" select="umbraco.library:GetMedia(.,0)" />
      <img src="{$node/umbracoFile}" alt="[image]" height="{$node/umbracoHeight}" width="{$node/umbracoWidth}" />
      

      </xsl:if>

    </xsl:template>
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 10, 2012 @ 21:51
    Jan Skovgaard
    0

    Hi Amir

    Not exactly - sorry that I was not more thorough in my previous answer.

    It's more like this

    <xsl:variable name="backgroundImage" select="$currentPage/headerBackgroundImage/MultiNodePicker/nodeId" />
    <xsl:variable name="node" select="umbraco.library:GetMedia($backgroundImage,0)" />
    <img src="{$node/umbracoFile}" alt="[image]" height="{$node/umbracoHeight}" width="{$node/umbracoWidth}" />

    This should work.

    /Jan

  • Amir Khan 1287 posts 2744 karma points
    Jan 10, 2012 @ 21:57
    Amir Khan
    0

    Thanks Jan! So when I call the templates, how do I make it loop for each item in the Multi-node picker? Something like below just returns the same items over and over instead of proceeding to the next one...

     

    <xsl:for-each select="$currentPage/headerBackgroundImage/MultiNodePicker/nodeId">

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 10, 2012 @ 22:39
    Jan Skovgaard
    0

    Hi Amir

    Ah, forgive me for being a bit slow on this. NOW I get what it is that you want to achieve. I thought you only wanted the first image from both variables.

    You need to mix the two results you're getting from the variables above.

    So try doing this instead. (from the top of my head - be aware of potential typos)

    <xsl:variable name="backgroundImage" select="$currentPage/headerBackgroundImage/MultiNodePicker/nodeId" />
    <xsl:variable name="factImage" select="$currentPage/headerFactPicker/MultiNodePicker/nodeId" />

    <xsl:variable name="images">
    <root>
         <xsl:for-each select="backgroundImage">
          <image>
              <id type="background">
                 <xsl:value-of select="." />
              </id>
          </image>
         </xsl:for-each>
         <xsl:for-each select="factImage">
              <image>
                <id type="fact">
                 <xsl:value-of select="." />
              </id>
               </image>
         </xsl:for-each>
    </root>
    </xsl:variable>

    <xsl:template match="/">

    <ul>
          <xsl:apply-templates select="msxsl:node-set($images)/image" />
    </ul>

    </xsl:template>

    <xsl:template match="image">

    <li>
         <xsl:apply-templates select="image/id[@type='background']" />
         <xsl:apply-templates select="image/id[@type='fact']" />
    </li>

    </xsl:template>

    <xsl:template match="id[@type='background']">
        <xsl:variable name="image" select="umbraco.library:GetMedia(.,0)" />
        <img src="{$image}" alt="" />
    </xsl:template>

    <xsl:template match="id[@type='fact']">
        <xsl:variable name="image" select="umbraco.library:GetMedia(.,0)" />
        <span><img src="{$image}" alt="" /></span>
    </xsl:template>

    Remember to declare msxsl as a namespace in the xsl:stylesheet section.

    Hope this helps.

    /Jan

  • Amir Khan 1287 posts 2744 karma points
    Jan 10, 2012 @ 23:25
    Amir Khan
    0

    Hmm, that just returns an empty <ul/>... Not throwing any errors and I added   xmlns:msxsl="urn:schemas-microsoft-com:xslt" and exclude-result-prefixes="msxsl.." to the stylesheet portion. Any ideas?


    Thanks again,

    Amir

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 11, 2012 @ 00:04
    Jan Skovgaard
    0

    Hi Amir

    Hmm, ok. Try doing this

    <textarea>
    <xsl:copy-of select="msxsl:node-set($images)" />
    </textarea>

    Does that return any XML?

    /Jan

  • Amir Khan 1287 posts 2744 karma points
    Jan 12, 2012 @ 20:17
    Amir Khan
    0

    Hi Jan, that just returns the following.

    <root />

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 12, 2012 @ 22:07
    Jan Skovgaard
    0

    Hi Amir

    Oops, seems like I forgot to run the loop on the variables...

    in the for-each it just says "backgroundImage" and "factImage". it should be $backgroungImage and $factImage like

    <xsl:for-each select="$backgroundImage"> and <xsl:for-each select="$factImage">

    /Jan

  • Amir Khan 1287 posts 2744 karma points
    Jan 18, 2012 @ 15:17
    Amir Khan
    0

    Hi Jan, Sorry for the VERY late response, this is still returning an empty list..

    Thanks again,

    Amir

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 18, 2012 @ 21:54
    Jan Skovgaard
    0

    Hi Amir

    What does your full code look like now?

    /Jan

  • Amir Khan 1287 posts 2744 karma points
    Jan 18, 2012 @ 21:56
    Amir Khan
    0

    Here it is Jan, again, thanks a TON for all of your help.

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


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

    <xsl:param name="currentPage"/>

    <xsl:variable name="backgroundImage" select="$currentPage/headerBackgroundImage/MultiNodePicker/nodeId" />
    <xsl:variable name="factImage" select="$currentPage/headerFactPicker/MultiNodePicker/nodeId" />

    <xsl:variable name="images">
    <root>
         <xsl:for-each select="$backgroundImage">
          <image>
              <id type="background">
                 <xsl:value-of select="." />
              </id>
          </image>
         </xsl:for-each>
         <xsl:for-each select="$factImage">
              <image>
                <id type="fact">
                 <xsl:value-of select="." />
              </id>
               </image>
         </xsl:for-each>
    </root>
    </xsl:variable>

    <xsl:template match="/">

    <ul>
          <xsl:apply-templates select="msxsl:node-set($images)/image" />
    </ul>

    </xsl:template>

    <xsl:template match="image">

    <li>
         <xsl:apply-templates select="image/id[@type='background']" />
         <xsl:apply-templates select="image/id[@type='fact']" />
    </li>

    </xsl:template>

    <xsl:template match="id[@type='background']">
        <xsl:variable name="image" select="umbraco.library:GetMedia(.,0)" />
        <img src="{$image}" alt="" />
    </xsl:template>

    <xsl:template match="id[@type='fact']">
        <xsl:variable name="image" select="umbraco.library:GetMedia(.,0)" />
        <span><img src="{$image}" alt="" /></span>
    </xsl:template>

    </xsl:stylesheet>
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 18, 2012 @ 22:02
    Jan Skovgaard
    0

    Hi Amir

    You're welcome :)

    Hmm, what happens if you just write out the $background variable like this <xsl:value-of select="$background" /> - does that give you an id? If so, what xml does it return if you make a

    <textarea>
    <xsl:copy-of select="$background" />
    </textarea>

    /Jan

  • Amir Khan 1287 posts 2744 karma points
    Jan 18, 2012 @ 22:12
    Amir Khan
    0

    Did you mean $backgroundImage? so like the following? It still returns nothing...

     

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


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

    <xsl:param name="currentPage"/>

    <xsl:variable name="backgroundImage" select="$currentPage/headerBackgroundImage/MultiNodePicker/nodeId" />
    <xsl:variable name="factImage" select="$currentPage/headerFactPicker/MultiNodePicker/nodeId" />

    <xsl:variable name="images">
    <root>
         <xsl:for-each select="$backgroundImage">
          <xsl:value-of select="$backgroundImage" />
         </xsl:for-each>
         <xsl:for-each select="$factImage">
              <image>
                <id type="fact">
                 <xsl:value-of select="." />
              </id>
               </image>
         </xsl:for-each>
    </root>
    </xsl:variable>

    <xsl:template match="/">

    <ul>
          <xsl:apply-templates select="msxsl:node-set($images)/image" />
    </ul>

    </xsl:template>

    <xsl:template match="image">

    <li>
         <xsl:apply-templates select="image/id[@type='background']" />
         <xsl:apply-templates select="image/id[@type='fact']" />
    </li>
    <textarea>
    <xsl:copy-of select="$backgroundImage" />
    </textarea>
    </xsl:template>

    <xsl:template match="id[@type='background']">
        <xsl:variable name="image" select="umbraco.library:GetMedia(.,0)" />
        <img src="{$image}" alt="" />
    </xsl:template>

    <xsl:template match="id[@type='fact']">
        <xsl:variable name="image" select="umbraco.library:GetMedia(.,0)" />
        <span><img src="{$image}" alt="" /></span>
    </xsl:template>

    </xsl:stylesheet>
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 18, 2012 @ 22:31
    Jan Skovgaard
    0

    Hi Amir

    Try placing it in the template that matchens "/" like this:

    <xsl:template match="/">

    <xsl:value-of select="$backgroundImage" /> <br />

    <textarea>
    <xsl:copy-of select="$backgroundImage" />
    </textarea>

    <!-- rest of your code in this template -->

    </xsl:template>

  • Amir Khan 1287 posts 2744 karma points
    Jan 18, 2012 @ 22:34
    Amir Khan
    0

    Yay! i get something, is this what was intended?

     

    1096<br /><textarea><nodeId>1096</nodeId><nodeId>1098</nodeId><nodeId>1094</nodeId></textarea><ul />
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 18, 2012 @ 22:37
    Jan Skovgaard
    0

    Hi Amir

    ok, that is good.

    Try moving the $images variable into the <xsl:template match="/"> template. Like this

    <xsl:template match="/">

    <xsl:variable name="images">
    <!-- the for-each loops goes here -->
    </xsl:variable>

    </xsl:template>

    And please let me see the whole code structure afterwards :)

    /Jan

  • Amir Khan 1287 posts 2744 karma points
    Jan 18, 2012 @ 22:41
    Amir Khan
    0

    Ah, back to just an empty <ul/>

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


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

    <xsl:param name="currentPage"/>

    <xsl:variable name="backgroundImage" select="$currentPage/headerBackgroundImage/MultiNodePicker/nodeId" />
    <xsl:variable name="factImage" select="$currentPage/headerFactPicker/MultiNodePicker/nodeId" />



    <xsl:template match="/">
        <xsl:variable name="images">
        <root>
             <xsl:for-each select="$backgroundImage">
                  <xsl:value-of select="$backgroundImage" />
             </xsl:for-each>
             <xsl:for-each select="$factImage">
                  <xsl:value-of select="$factImage" />
             </xsl:for-each>
        </root>
    </xsl:variable>
    <ul>
          <xsl:apply-templates select="msxsl:node-set($images)/image" />
    </ul>

    </xsl:template>

    <xsl:template match="image">

    <li>
         <xsl:apply-templates select="image/id[@type='background']" />
         <xsl:apply-templates select="image/id[@type='fact']" />
    </li>

    </xsl:template>

    <xsl:template match="id[@type='background']">
        <xsl:variable name="image" select="umbraco.library:GetMedia(.,0)" />
        <img src="{$image}" alt="" />
    </xsl:template>

    <xsl:template match="id[@type='fact']">
        <xsl:variable name="image" select="umbraco.library:GetMedia(.,0)" />
        <span><img src="{$image}" alt="" /></span>
    </xsl:template>

    </xsl:stylesheet>
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 18, 2012 @ 22:46
    Jan Skovgaard
    0

    That makes sense, since you changed the $images variable, which was not the intention :)

    The whole code should 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:msxsl="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:ucomponents.media="urn:ucomponents.media"
      exclude-result-prefixes="msxml
     umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes
    Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings
    Exslt.ExsltSets ucomponents.media ">


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

    <xsl:param name="currentPage"/>

    <xsl:variable name="backgroundImage" select="$currentPage/headerBackgroundImage/MultiNodePicker/nodeId" />
    <xsl:variable name="factImage" select="$currentPage/headerFactPicker/MultiNodePicker/nodeId" />

    <xsl:template match="/">
    <xsl:variable name="images">
    <root>
         <xsl:for-each select="backgroundImage">
          <image>
              <id type="background">
                 <xsl:value-of select="." />
              </id>
          </image>
         </xsl:for-each>
         <xsl:for-each select="factImage">
              <image>
                <id type="fact">
                 <xsl:value-of select="." />
              </id>
               </image>
         </xsl:for-each>
    </root>
    </xsl:variable>
    <ul>
          <xsl:apply-templates select="msxsl:node-set($images)/image" />
    </ul>

    </xsl:template>

    <xsl:template match="image">

    <li>
         <xsl:apply-templates select="image/id[@type='background']" />
         <xsl:apply-templates select="image/id[@type='fact']" />
    </li>

    </xsl:template>

    <xsl:template match="id[@type='background']">
        <xsl:variable name="image" select="umbraco.library:GetMedia(.,0)" />
        <img src="{$image}" alt="" />
    </xsl:template>

    <xsl:template match="id[@type='fact']">
        <xsl:variable name="image" select="umbraco.library:GetMedia(.,0)" />
        <span><img src="{$image}" alt="" /></span>
    </xsl:template>

    </xsl:stylesheet>

    What i'm thinking is that perhaps the reason why we got nothing returned earlier on was that the variable was defined outside the xsl:template match="/" - I'm not sure however. But since you can get the xml by making a copy-of on the $backgroundImage variable it should be possible to fetch the nodeId's in the loop.

    Let's see if it works :)

    /Jan

  • Amir Khan 1287 posts 2744 karma points
    Jan 18, 2012 @ 22:52
    Amir Khan
    0

    Back to the empty UL again...Thanks again for helping with this, I think I'm starting to actually see what's going on.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 18, 2012 @ 22:54
    Jan Skovgaard
    0

    argh, sorry! Once again I forgot to place the $ sign in front of the bakcgroungImage and factImage variables in the for-each loops.

    It should of course be $backgroundImage and $factImage.

    Hope this does the trick now...:)

    /Jan

  • Amir Khan 1287 posts 2744 karma points
    Jan 18, 2012 @ 22:57
    Amir Khan
    0

    Its actually still returning nothing, Is this one of those tasks that would be super simple in Razor?

     

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


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

    <xsl:param name="currentPage"/>

    <xsl:variable name="backgroundImage" select="$currentPage/headerBackgroundImage/MultiNodePicker/nodeId" />
    <xsl:variable name="factImage" select="$currentPage/headerFactPicker/MultiNodePicker/nodeId" />

    <xsl:template match="/">
    <xsl:variable name="images">
    <root>
         <xsl:for-each select="$backgroundImage">
          <image>
              <id type="background">
                 <xsl:value-of select="." />
              </id>
          </image>
         </xsl:for-each>
         <xsl:for-each select="$factImage">
              <image>
                <id type="fact">
                 <xsl:value-of select="." />
              </id>
               </image>
         </xsl:for-each>
    </root>
    </xsl:variable>
    <ul>
          <xsl:apply-templates select="msxsl:node-set($images)/image" />
    </ul>

    </xsl:template>

    <xsl:template match="image">

    <li>
         <xsl:apply-templates select="image/id[@type='background']" />
         <xsl:apply-templates select="image/id[@type='fact']" />
    </li>

    </xsl:template>

    <xsl:template match="id[@type='background']">
        <xsl:variable name="image" select="umbraco.library:GetMedia(.,0)" />
        <img src="{$image}" alt="" />
    </xsl:template>

    <xsl:template match="id[@type='fact']">
        <xsl:variable name="image" select="umbraco.library:GetMedia(.,0)" />
        <span><img src="{$image}" alt="" /></span>
    </xsl:template>

    </xsl:stylesheet>
Please Sign in or register to post replies

Write your reply to:

Draft