2

I am quite new to Content Query WebPart. I have a list which as a 'Hyperklink or Picture' column. I have added below markup in itemstyle.xsl to show hyperlink

<xsl:template name="CQWPStyle" match="Row[@Style='CQWPStyle']" mode="itemstyle">
 <html>
<table width="100%">
<xsl:if test="count(preceding-sibling::*)=0">
    <tr>
    <td width="10%" valign="top"><div class="item"><b>Title</b></div></td>
    <td width="10%" valign="top"><div class="item"><b>Address</b></div></td>
    <td width="10%" valign="top"><div class="item"><b>Area</b></div></td>   
    <td width="10%" valign="top"><div class="item"><b>ChoiceCol</b></div></td>  
    <td width="10%" valign="top"><div class="item"><b>DateTimeCol</b></div></td>    
</tr>
</xsl:if>
<tr>       
    <td width="10%" valign="top">
        <div class="item">
            <xsl:value-of select="@Title" />
        </div>
    </td>
    <td width="10%" valign="top">
        <div class="item">
            <xsl:value-of select="@Address" disable-output-escaping="yes"  />
        </div>
    </td>
    <td width="10%" valign="top">
        <div class="item">
            <xsl:value-of select="@Area" />
        </div>
    </td>
    <td width="10%" valign="top">
        <div class="item">
            <xsl:value-of select="@ChoiceCol" />
        </div>
    </td>
        <td width="10%" valign="top">
        <div class="item">
            <xsl:value-of select="@DateTimeCol" />
        </div>
    </td>
    <td width="10%" valign="top">
        <div class="item">          
            <!--Variable declared to read the link from the column Link-->

            <xsl:variable name="ActualLink" select="substring-before(@HyperLinkCol,',')"/>
            <xsl:variable name="FriendlyName" select="substring-after(@HyperLinkCol,',')"/>

            <!-- Image to the hyperlink-->

<a href="{$ActualLink}"><xsl:value-of select="$FriendlyName"/></a>



        </div>
    </td>        
</tr>
</table>
</html>

All other columns show as expected. However, the hyperlink column does not show. Kindly let me know, what I am missing.

0
1

[Updated]

<xsl:variable name="BeforeLink">   
    <xsl:value-of select="substring-before(@HyperLinkCol, ',')" />                        
</xsl:variable>
<xsl:variable name="AfterLink">   
    <xsl:value-of select="substring-after(@HyperLinkCol, ',')" />                     
</xsl:variable>

//// Use those variables
<a href="{$BeforeLink}">
     <xsl:value-of disable-output-escaping="yes" select="$AfterLink"/>
 </a>

Instead of assigning values in variable and then using those variables, try to use the values directly.

If you want to display only link, use following code:

<a href="{substring-before(@HyperLinkCol,',')}"><xsl:value-of select="substring-after(@HyperLinkCol,',')"/></a>

And if you want to display am image, use below code-snippet:

<img src="{substring-before(@HyperLinkCol,',')}" alt="{substring-after(@HyperLinkCol,',')}" />    
7
  • Tried above markup. Still no luck. it renders output as '<a href=""></a>'
    – shoab
    May 7 '17 at 10:16
  • I have updated my code. May 7 '17 at 10:30
  • Thanks for the trails divya. However it is still not working. I used your updated markup
    – shoab
    May 7 '17 at 11:51
  • Any update please....
    – shoab
    May 8 '17 at 5:53
  • I believe this is a very basic question for Stack Exchange users. Till now 27 views but no working answer yet... Any pointer / link will also help me move forward. Thank you.
    – shoab
    May 9 '17 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.