Copied to clipboard

Flag this post as spam?

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


  • Devin 87 posts 251 karma points
    Nov 15, 2013 @ 17:36
    Devin
    0

    Link affects H5 and image

    Hi guys,

    I have a problem with a link to an image creating a link to the H5 also, in my code. I have tried closing the href before the H5, but it's still turning the H5 into a link. I want the image to be linked, but not the H5.

    Here's a pic of how it works:

    http://oi41.tinypic.com/2h3ac1c.jpg

    (The left part is the image, created by a crop which links to a page). The H5 is the text on the right (that I don't want linking) and the arrow is the slidearrowLink).

    <h5><xsl:value-of select="@nodeName"/></h5>

    The above is the H5 section that's being converted into a link and below is the entire code. Thanks!

    <?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:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <xsl:variable name="slideItems" select="$currentPage/child::*[@isDoc][showElement = 1]" />    
    <!-- <xsl:variable name="slideItems" select="$currentPage/descendant::*[@isDoc][showElement = 1]" />     -->
    <xsl:template match="/">
                   
    <xsl:apply-templates select="$slideItems" mode="navigator">
             
    <xsl:sort select="umbraco.library:FormatDateTime(@updateDate, 'dd.MM.yy.hh.mm.ss')" order="descending"/>
                 
    </xsl:apply-templates>  
             
    </xsl:template>
           
           
    <xsl:template match="*" mode="navigator">
       
    <xsl:variable name = "articleImage" select = "pageImage" />
     
    <xsl:if test = "$articleImage != '' and string(showElement) = '1'">
     
     
    <div class="rsContent">
               
         
    <xsl:variable name = "photo" select="umbraco.library:GetMedia($articleImage, 0)/umbracoFile" />
                 
         
    <a class="rsLink" href="{umbraco.library:NiceUrl(@id)}"><span class="rsCaption">Slide desc</span></a>

               
    <a class="rsImg" src="/imagegen.ashx?image={$photo}&amp;width=760&amp;Compression=70&amp;Allow" width="100%">
                   
    <xsl:if test="normalize-space($articleImage)">

                       
    <!-- Grab the media node -->
                       
    <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($articleImage, 0)" />

                     
    <!-- Select the banner crop (if present) -->    
                       
    <xsl:variable name="bannerCrop" select="$mediaNode//crop[@name = 'banner']" />
                     
    <xsl:if test="$bannerCrop">

                           
    <!-- Override the img tag src attribute -->                        
                         
    <xsl:attribute name="href"><xsl:value-of select="$bannerCrop/@url" /></xsl:attribute>                
                       
    </xsl:if>
                   
    </xsl:if>
                   
    <div class="rsTmb">
                     
    <h5><xsl:value-of select="@nodeName"/></h5>
                     
    <div class="slideArrowLink">
                           
    <a style="color: #fff;" href="{umbraco.library:NiceUrl(@id)}"><img src="/images/slidearrow.jpg" /></a>
                     
    </div>
                 
    </div>
             
    </a>
                 
    <p class="rsABlock sampleBlock">
                   
    <a style="color: #fff;" href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="umbraco.library:TruncateString(firstParagraph, number(150), '' )" disable-output-escaping="no" />... Read More >></a>
                   
    </p>
               
    </div></xsl:if>
           
         
    </xsl:template>  
    </xsl:stylesheet>
  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Nov 15, 2013 @ 20:00
    Dennis Aaen
    0

    Hi Devin,

    I have just looked into your coode. I only reason why your H5 turns into a link, is because the hole part is wrapped in a link as I see it.Correct me if I'm wrong.

    <a class="rsImg" src="/imagegen.ashx?image={$photo}&amp;width=760&amp;Compression=70&amp;Allow" width="100%">
        <xsl:if test="normalize-space($articleImage)">

        <!-- Grab the media node -->
        <xsl:variable name="mediaNode" s    elect="umbraco.library:GetMedia($articleImage, 0)" />

    <!-- Select the banner crop (if present) -->   
        <xsl:variable name="bannerCrop" select="$mediaNode//crop[@name = 'banner']" />
        <xsl:if test="$bannerCrop">

        <!-- Override the img tag src attribute -->                       
        <xsl:attribute name="href"><xsl:value-of select="$bannerCrop/@url" /></xsl:attribute>               
        </xsl:if>
        </xsl:if>
        <div class="rsTmb">
            <h5><xsl:value-of select="@nodeName"/></h5>
            <div class="slideArrowLink">
            <a style="color: #fff;" href="{umbraco.library:NiceUrl(@id)}"><img src="/images/slidearrow.jpg" /></a>
         </div>
        </div>
    </a>

    I hope that I have spotted why your H5 turns into a link. I have highlighted the code I think why your H5 turns into a link

    Hope this helps you.

    /Dennis

  • Devin 87 posts 251 karma points
    Nov 18, 2013 @ 11:52
    Devin
    0

    Hi Dennis,

    Thanks for taking a look. Strange because in my live example it's not wrapping the entire block of code!

    Even when closing the href earlier, the H5 text is still linking to the image. I think it's getting the link from the href attribute, because when I remove that the link disappears?

    Thanks

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies