Copied to clipboard

Flag this post as spam?

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


  • Pat 56 posts 147 karma points
    Jan 27, 2012 @ 11:13
    Pat
    0

    get media displaying nothing

    Nothing is showing up using this in my XSLT, for some reason. I pull this through into a webpage using <umbraco:Macro Alias="ListNewServices" runat="server"></umbraco:Macro> and it pulls the title and the content fine but nothing at all seems to go through for the image.

    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
        <div class="title">
          <div style="float:left;width:1000px;margin-left:-40px;">
            <!--<xsl:value-of select="iconServices" disable-output-escaping="yes"/>-->
            <h2><xsl:value-of select="title" disable-output-escaping="yes"/></h2>
          </div>
        </div>    
          <div class="content" style="float:left;width:1000px;margin-left:-40px;">
             <xsl:variable name="mediaId" select="number($currentPage/*[name() = 'iconServices'])"  />
            <xsl:if test="$mediaId > 0">
            <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
            <xsl:if test="$mediaNode/umbracoFile">
        <img src="{umbraco.library:GetMedia(image, 0)/umbracoFile}" />
            </xsl:if>
            </xsl:if>
            <h3><xsl:value-of select="content" disable-output-escaping="yes"/></h3>
            <hr/>
          </div>
      
    </xsl:for-each>

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jan 27, 2012 @ 11:16
    Ismail Mayat
    0

    Pat,

    try replacing the 0 with false() if that wont work try true()

    Regards

    Ismail

  • Pat 56 posts 147 karma points
    Jan 27, 2012 @ 11:20
    Pat
    0

    Hi,

    Tried that but no change. There is nothing at all appearing even an empty space.

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Jan 27, 2012 @ 11:32
    Chriztian Steinmeier
    1

    Hi Pat,

    You're looping through the children of $currentPage, but when you pick the image you're taking it from a property on $currentPage - is that right? If you mean to take it from the current page in the loop, here's how:

    <xsl:for-each select="$currentPage/*[@isDoc and not(umbracoNaviHide = 1)]">
        <div class="title">
            <div style="float:left;width:1000px;margin-left:-40px;">
                <!--<xsl:value-of select="iconServices" disable-output-escaping="yes" />-->
                <h2><xsl:value-of select="title" disable-output-escaping="yes" /></h2>
            </div>
        </div>    
        <div class="content" style="float:left;width:1000px;margin-left:-40px;">
            <xsl:variable name="mediaId" select="iconServices" />
            <xsl:if test="$mediaId > 0">
                <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
                <xsl:if test="$mediaNode/umbracoFile">
                    <img src="{$mediaNode/umbracoFile}" />
                </xsl:if>
            </xsl:if>
            <h3><xsl:value-of select="content" disable-output-escaping="yes" /></h3>
            <hr/>
        </div>
    </xsl:for-each>

    /Chriztian 

  • Pat 56 posts 147 karma points
    Jan 27, 2012 @ 11:38
    Pat
    0

    Hi Chriztian,

    My tree is like this:

    Services

    - Service 1

    - Service 2

    - Service 3 etc

    The macro is on "Services" and it pulls through any new items which appear beneath it, so at the mo it has 3 services (a title, some content, and an image on each one). So I am pulling the data from the child pages of the Services page, to that page if that makes sense?

  • Pat 56 posts 147 karma points
    Jan 27, 2012 @ 11:39
    Pat
    0

    Thanks Chriztian, that has done the trick perfectly. Many thanks.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jan 27, 2012 @ 16:45
    Jeroen Breuer
    0

    If you don't want to use library.GetMedia you should have a look at DAMP. It can store the full media xml which makes it easier to use in XSLT.

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft