Skip to content

Use Secondary Field in a SharePoint Feed As A Title In RSS Feed Reader Web Part XSL

by on February 3, 2012

You have two SharePoint Applications and want to display a corporate feed from one on another. Say, for whatever reason, you have decided that you want to use a specified custom field to display as your title in an RSS Feed Reader in SharePoint (2007 or 2010). Perhaps this has to do with linked lists, multilingual setups, legacy configuration, or displaying a nice URL. Or perhaps you just want to show a subtitle or summary field you have created.

Well, normally this would be simple, just replace the current field with a different one. Unfortunately, due to shortcut malformed feeds, SharePoint throws a wrench in the works. Instead of each field existing, you get two fields; the title, and everything else.

So your title may look something like:

<b>DisplayTitle:</b> Here is my custom display title!</div>

Solution:

Use secondary field as title with nested substring-after and substring-before parsing

To get the contents of <b>DisplayTitle: </b>…</div> do the following

  1. Create a variable for description
  2. Take description variable and apply: substring-after(description,’<b>DisplayTitle:</b> ’)
  3. Take result and apply: <xsl value-of select=”substring-before(description,‘</div>’)” />

 

For just one item:

<xsl:value-of select="substring-before(substring-after($item_title,’DisplayTitle:&lt;/b&gt; ‘),’&lt;/div’)" />

Note: you can also concatenate a couple of items and/or format as desired

Example in Context:

<xsl:variable name="item_link" select="link" />
<xsl:variable name="item_title" select="description" />

<div class="pressitemdiv">
            <a>
<xsl:attribute name="href" >
<xsl:value-of select="$item_link"/>
</xsl:attribute>
<xsl:attribute name="title">Read Article: <xsl:value-of select="substring-before(substring-after($item_title,’DisplayTitle:&lt;/b&gt; ‘),’&lt;/div&gt;’)" />
</xsl:attribute>
<xsl:value-of select="substring-before(substring-after($item_title,’DisplayTitle:&lt;/b&gt; ‘),’&lt;/div&gt;’)" />
</a>
</div>

NOTE: Do not cut and paste code – quote marks are converted by WordPress engine.

Additional Resources

Templates: http://spxslt.codeplex.com/documentation

Advertisements
One Comment
  1. QUICK NOTE

    Restricted legnth substrings format like:

    substring(string,firstcharacter#,lastcharacternum)
    substring(@body,0,300)

    http://en.wikipedia.org/wiki/XSLT_elements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: