Copied to clipboard

Flag this post as spam?

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


  • Martin Vingaard 39 posts 60 karma points
    Apr 13, 2011 @ 10:11
    Martin Vingaard
    0

    Childnote img and RTE

    At the moment im working with a macro that gathers the RTE and IMG from all childnotes

    The code goes like this:

    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
        <!--
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
        -->
      <div id="buyProduct">
         <div id="buyImage">
           <xsl:if test="$currentPage/*/productPicture != ''">
             <img src="{umbraco.library:GetMedia($currentPage/*/productPicture,0)/umbracoFile}" />
         </xsl:if>
        </div>
        <div id="buyText">
          <h2><span class="grey"><xsl:value-of select="productTitle"  disable-output-escaping="yes"/></span></h2>
          <xsl:value-of select="productText" disable-output-escaping="yes"/>
        </div>
          <div id="clear"></div>
      </div>

    An error accures regarding the gathering of the productPicture

    <div id="buyImage">
           <xsl:if test="$currentPage/*/productPicture != ''">
             <img src="{umbraco.library:GetMedia($currentPage/*/productPicture,0)/umbracoFile}" />
         </xsl:if>
        </div>

    For each child note i get the correct RTE data, but i get the picture from the first childnote for each childnote.

    And OFC what i want is to display the productPicture from each childnote, and not just the same IMG on every post.

    Hope someone can help.

  • Rob Watkins 369 posts 701 karma points
    Apr 13, 2011 @ 10:37
    Rob Watkins
    0

    First of all, I'm surprised you are getting the correct text, given your for-each is only looping through the first sub level of the current page.

    Secondly, if the syntax for getting the text does in fact work, why don't you just duplicate for the image? So replace $currentPage/*/productPicture with just productPicture ?

    What I would have thought you would want is to change your loop to use the all descendants axis:

    <xsl:for-each select="$currentPage//*[@isDoc and string(umbracoNaviHide) != '1']">

    ...which will make the current element in each pass of the loop the child page, at whatever level, so you can just use productTitle, productText and productPicture.

  • Martin Vingaard 39 posts 60 karma points
    Apr 13, 2011 @ 10:49
    Martin Vingaard
    0

    Man that worked... im new at this, so sometimes i cant always figure it out.

    Thanks alot.

  • Rob Watkins 369 posts 701 karma points
    Apr 13, 2011 @ 10:54
    Rob Watkins
    0

    Awesome, glad it worked!

Please Sign in or register to post replies

Write your reply to:

Draft