Copied to clipboard

Flag this post as spam?

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


  • Natasha 79 posts 195 karma points
    Jul 12, 2013 @ 17:27
    Natasha
    0

    Display images from other nodes

    Hi All

    I have been stuck on this for almost a week.  I have inherited a site at work which has a macro to display a linked image. It works, however it defaults to the first image/node all the time rather than allowing users to select which image they want from the multiple picker.  I have tried several things to fix it, but nothing seems to work.  The site is 4.7, but I knoow that it was upgraded from 4.5 so some of it could be in the old schema.  Any help to get this working would be appreciated.  

    the xslt is below:

    <?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:import href="../xslt/imageLink.xslt" />
        <xsl:import href="../xslt/globalVariables.xslt" />
        <xsl:output method="xml" omit-xml-declaration="yes" />
        <xsl:param name="currentPage" />
        <xsl:param name="websiteRoot" select="$currentPage/ancestor-or-self::node[@nodeTypeAlias='homePage']" />
        <xsl:template match="/">
            <xsl:variable name="nodeDefaults" select="umbraco.library:GetXmlNodeById($nodeIdDefaults)" />
            <xsl:choose>
                <xsl:when test="string-length($currentPage/data[@alias='itemBannerAdvert']) &gt; 0">
                    <xsl:for-each select="Exslt.ExsltStrings:split($currentPage/data[@alias='itemBannerAdvert'], ',')">
                        <xsl:if test="position() &gt;= 0">
                            <xsl:variable name="nodeBannerAdvert" select="umbraco.library:GetXmlNodeById(current())" />
                            <xsl:if test="not(contains(umbraco.library:GetXmlNodeById(current()), 'No published item exist'))">
                                <xsl:call-template name="displayBannerAdvert">
                                    <xsl:with-param name="src" select="$currentPage/data[@alias='image']" />
                                    <xsl:with-param name="alt" select="$nodeBannerAdvert/data[@alias='altText']" />
                                    <xsl:with-param name="url">
    <xsl:choose>
    <xsl:when test="$nodeBannerAdvert/data[@alias='url']/links/link/@type='internal'">
    <xsl:value-of select="umbraco.library:NiceUrl($nodeBannerAdvert/data[@alias='url']/links/link/@link)" />
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$nodeBannerAdvert/data[@alias='url']/links/link/@link" />
    </xsl:otherwise>
    </xsl:choose>
    </xsl:with-param> 
                                </xsl:call-template>
                            </xsl:if>
                        </xsl:if>
                    </xsl:for-each>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:if test="not(contains($nodeDefaults, 'No published item exist'))">
                        <xsl:call-template name="displayBannerAdvert">
                            <xsl:with-param name="src" select="$nodeDefaults/data[@alias='itemBannerAdvert_image']" />
                            <xsl:with-param name="alt" select="$nodeDefaults/data[@alias='itemBannerAdvert_altText']" />                        
    <xsl:with-param name="url">
    <xsl:choose>
    <xsl:when test="$nodeDefaults/data[@alias='itemBannerAdvert_url']/links/link/@type='internal'">
    <xsl:value-of select="umbraco.library:NiceUrl($nodeDefaults/data[@alias='itemBannerAdvert_url']/links/link/@link)" />
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$nodeDefaults/data[@alias='itemBannerAdvert_url']/links/link/@link" />
    </xsl:otherwise>
    </xsl:choose>
    </xsl:with-param> 
                        </xsl:call-template>
                    </xsl:if>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:template>
        <xsl:template name="displayBannerAdvert">
            <xsl:param name="src" />
            <xsl:param name="alt" />
            <xsl:param name="url" />
            <xsl:variable name="imageSrc">
                <xsl:if test="string-length($src) &gt; 0">
                    <xsl:value-of select="$src" />
                </xsl:if>
            </xsl:variable>
            <xsl:variable name="imageAlt">
                <xsl:if test="string-length($alt) &gt; 0">
                    <xsl:value-of select="$alt" />
                </xsl:if>
            </xsl:variable>
            <xsl:variable name="linkUrl">
                <xsl:if test="string-length($url) &gt; 0">
                    <xsl:value-of select="$url" />
                </xsl:if>
            </xsl:variable>
            <xsl:variable name="openInNewWindow">
                <xsl:choose>
                    <xsl:when test="contains($linkUrl, $urlPlayEngland)">
                        <xsl:value-of select="number(1)" />
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="number(0)" />
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <xsl:if test="string-length($imageSrc) &gt; 0">
                <xsl:call-template name="displayImageLink">
                    <xsl:with-param name="mediaId" select="$imageSrc" />
                    <xsl:with-param name="imgAlt" select="$imageAlt" />
                    <xsl:with-param name="imgStyle" select="'margin-top:30px; width:140px; height:400px;'" />
                    <xsl:with-param name="aHref" select="$linkUrl" />
                    <xsl:with-param name="openInNewWindow" select="$openInNewWindow" />
                </xsl:call-template>
            </xsl:if>
        </xsl:template>
    </xsl:stylesheet>' 
Please Sign in or register to post replies

Write your reply to:

Draft