2

I'm having trouble getting the URL and description to show as separate items in SharePoint 2013.

I'm trying to display the description as the text of the Link and the URL as the HREF value in the a tag below.

My hyperlink column Name is "Read_x0020_More_x0020_Link"

This doesn't return anything

<xsl:value-of select="substring-after(@Read_x0020_More_x0020_Link,',')"/>

Here is my Full XSLT:

 <xsl:template name="TopStory" match="Row[@Style='TopStory']" mode="itemstyle">
    <xsl:variable name="SafeLinkUrl">
        <xsl:call-template name="OuterTemplate.GetSafeLink">
            <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
        </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="SafeImageUrl">
        <xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
            <xsl:with-param name="UrlColumnName" select="'ImageUrl'"/>
        </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="DisplayTitle">
        <xsl:call-template name="OuterTemplate.GetTitle">
            <xsl:with-param name="Title" select="@Title"/>
            <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
        </xsl:call-template>
    </xsl:variable>
    <div class="top-story">
          <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>              
<span class="top-story-title">
<xsl:value-of select="$DisplayTitle"/>
</span>        
            <span class="top-story-description">
                <xsl:value-of select="@Description" />
            </span>
            <span class="top-story-date">
              <xsl:value-of select="ddwrt:FormatDateTime(string(@Date) ,1033 ,'dd-MMM-yyyy')"/>
            </span>
            <a href="#" class="btn btn-default">
              <xsl:value-of select="substring-after(@Read_x0020_More_x0020_Link,',')"/>
          </a>

    </div>
</xsl:template>
0

Your first example of code just needs a slight change. You are using the internal name and need to use the XSL Field Name. Add "x005F_" before all "x0020" so your code will read:

  <xsl:value-of select="substring-after(@Read_x005F_x0020_More_x005F_x0020_Link,',')"/>

Reference: Customizing Content Query Web Part and Item

Don't know if you still need an answer to this but hopefully might help someone else.

0

Something like this could work as well...

Create two separate variables and use the following xslt functions to extract the link from the description:

<xsl:variable name="ReadMoreLink">   
    <xsl:value-of select="substring-before(@Read_x0020_More_x0020_Link, ',')" />                        
</xsl:variable>
<xsl:variable name="ReadMoreDescription">   
    <xsl:value-of select="substring-after(@Read_x0020_More_x0020_Link, ',')" />                     
</xsl:variable>

Then you could use this markup to display the results of both variables:

 <a href="{$ReadMoreLink}" class="btn btn-default">
     <xsl:value-of disable-output-escaping="yes" select="$ReadMoreDescription"/>
 </a>

If there is ever an instances where no description is entered, you can prevent errors by also including an if/else statements around your substring functions.

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.