I have a unique scenario where I need to compare values for conditional formatting of my Content Query Web Part. In most circumstances this is pretty easy, and we thought this was working for the most part in our implementation.
SharePoint 2010 I am using a cqwp to show 9 items from one list. The list uses a managed metadata field. I compare this field to the page name (which I get from parsing the URL) using if statements and contains(@Metadata, $MetadataMatch) or not(contains(@Metadata, $MetadataMatch) to determine which items I highlight. The problem that comes in to play is that the Page name is Plan and the item I am pulling into the CQWP has a value called Project Management Plan it highlights the item. I cant do an equals for this because the @Metadata field could have multiple items. I tried checking to see if there is a ; prior to Plan then it would show but that doesn't work at all, even though it is part of the string. I know working with MM can be a pain for things like this but I am hoping there is some sort of fix or workaround. Ill update this with code once I get access to it again later this afternoon.
<xsl:variable name="PageTitleLong">
<xsl:call-template name="OuterTemplate.GetPageNameFromUrlRecursive">
<xsl:with-param name="Url" select="$PageUrl" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="PageTitle">
<xsl:value-of select="translate((substring-before($PageTitleLong, '.')), '-', ' ')" />
</xsl:variable>
<xsl:variable name="TitleNoSpace">
<xsl:value-of select="translate(@Title, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ','abcdefghijklmnopqrstuvwxyz')" />
</xsl:variable>
<xsl:variable name="MetadataMatch">
<xsl:value-of select="$PageTitle" />
</xsl:variable>
<div class="EI-Disc-Outer">
<table width="100%">
<tr>
<td width="32px">
<a href="{$SafeLinkUrl}" title="Click to view {$DisplayTitle}" >
<img src="/ip/ep/Style Library/Images/icons/{$TitleNoSpace}32x32.png" border="0">
<xsl:if test="contains(@Metadata, $MetadataMatch)">
<xsl:attribute name="class"></xsl:attribute>
</xsl:if>
<xsl:if test="not(contains(@Metadata, $MetadataMatch))">
<xsl:attribute name="class">EI-Disc-Opacity</xsl:attribute>
</xsl:if>
</img>
</a>
</td>