Copied to clipboard

Flag this post as spam?

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


  • Ulla Skaanning 67 posts 97 karma points
    Nov 21, 2011 @ 21:55
    Ulla Skaanning
    0

    Show image in news list, will not recognize associated image

    Hi

    I have started out with the Umbraco Business template, and am modifying it to fit my needs. In the news section I would like the list of news to display an associated image next to each news teaser.

    In the NewsArticle doc type I have made a mediapicker with alias "newsPicsmall" on the introduction tab. This is the image I want to show in the list. (FYI: I have also added mediapicker with alias "newsPic" to the article tab, but that shouldn't affect this right?)

    Then I have added the following to the umbNewsListItems.xslt:

    <xsl:choose>
    <xsl:when test="./data [@alias = 'newsPicsmall'] !=''">
    <xsl:element name="img">
    <xsl:attribute name="src">

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

    </xsl:attribute>
    </xsl:element>
    </xsl:when>
    <xsl:otherwise>
    <img src="http://-----/css/pictures/EmptyImage.jpg" />
    </xsl:otherwise>
    </xsl:choose>

    It calls in the "substitute image" just fine, but it will not recognize that an image has been selected. Even though I have selected an image for all news articles, using the media picker with alias "newsPicsmall", it still shows the substitue image for all articles.

    I hope someone can help me, I am at my wits end here .

    Cheers

    Ulla

    P.S the above code works fine on another site where I'm using it to call in pictures in a list of employees, but that site is Umb v. 4.0.4.1, Could the version be what's causing the trouble?

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Nov 21, 2011 @ 22:01
    Chriztian Steinmeier
    1

    Hi Ulla,

    Yep - since Umbraco 4.1 beta2 the XML format has been changed (for the better!) - you should be able to get by with this:

    <xsl:choose>
        <xsl:when test="normalize-space(newsPicsmall)">
            <img src="{umbraco.library:GetMedia(newsPicsmall, false())/umbracoFile}" />
        </xsl:when>
        <xsl:otherwise>
            <img src="http://-----/css/pictures/EmptyImage.jpg" />
        </xsl:otherwise>
    </xsl:choose>

    /Chriztian

  • Jordy Vialoux 73 posts 103 karma points
    Nov 21, 2011 @ 22:02
    Jordy Vialoux
    0

    Need a bit more information - are you wanting to list mulitple news articles then directs the user to the article they click on?

  • Ulla Skaanning 67 posts 97 karma points
    Nov 21, 2011 @ 22:07
    Ulla Skaanning
    0

    THANKS Guys

    Wow that's quick response!! and the above code from Chriztian works like a treat :D

    You've just saved my day ;)

    Cheers

    Ulla

Please Sign in or register to post replies

Write your reply to:

Draft