Display special character in SharePoint global navigation, quick launch and breadcrumb

On my SharePoint global navigation menu, quick launch or breadcrumb, for pages that has special character in their name, the characters are encoded. For example, “Health & Safety” displays as “Health & Safety”, “Tomorrow’s Leader” displays as “Tomorrow#39;s”.

The solution for the global navigation is to add

EncodeTitle=”false” in the AspMenu control.

<!-- ------------| TOP NAVIGATION  |------------ -->
<div>
<!-- top navigation publishing data source -->
<SharePoint:AspMenu
   ID="TopNavigationMenuV4"
   Runat="server"
   EnableViewState="false"
   DataSourceID="topSiteMap"
   AccessKey="<%$Resources:wss,navigation_accesskey%>"
   UseSimpleRendering="true"
   UseSeparateCss="false"
   Orientation="Horizontal"
   StaticDisplayLevels="1"
   MaximumDynamicDisplayLevels="1"
   SkipLinkText=""
   EncodeTitle="false"
   CssClass="s4-tn"/>

<asp:SiteMapDataSource
   ShowStartingNode="False"
   SiteMapProvider="CombinedNavSiteMapProvider"
   id="topSiteMap"
   runat="server"/>
</div>
<!-- ------------| TOP NAVIGATION  |------------ -->
The solution for the quick launch is to add EncodeTitle=”false” in the quick launch control:
<SharePointWebControls:AspMenu id="V4QuickLaunchMenu" runat="server" EnableViewState="false" DataSourceId="QuickLaunchSiteMap" UseSimpleRendering="true" EncodeTitle="false" UseSeparateCss="false" Orientation="Vertical" StaticDisplayLevels="10" MaximumDynamicDisplayLevels="7" SkipLinkText="" CssClass="s4-ql noindex" />
The solution for the breadcrumb is different. We need to add javascript to do this. Here is the js code:
<script type="text/javascript">

    jQuery(document).ready(function () {

        fixSiteTitleBug();

    });

    function fixSiteTitleBug()
    {
        var searchAmp = '&amp;';
        var replaceAmp = '&';
        var searchQuote = '#39;';
        var replaceQuote = '\'';

        // Fix Quick Launch items
        var html = jQuery('#s4-leftpanel-content').html().replace(searchPattern, replacement);
        jQuery('#s4-leftpanel-content').html(html);

        // Fix breadcrumb items
        jQuery('a.SolidBreadCrumbRoot').each(function () {
            jQuery(this).html(jQuery(this).html().replace(searchAmp , replaceAmp ));
        });

        jQuery('a.SolidBreadCrumb').each(function () {
            jQuery(this).html(jQuery(this).html().replace(searchAmp , replaceAmp ));
        });

        jQuery('.SolidBreadCrumbCurrent').each(function () {
            jQuery(this).html(jQuery(this).html().replace(searchAmp , replaceAmp ));
        });

        jQuery('a.SolidBreadCrumbRoot').each(function () {
            jQuery(this).html(jQuery(this).html().replace(searchQuote, replaceQuote));
        });

        jQuery('a.SolidBreadCrumb').each(function () {
            jQuery(this).html(jQuery(this).html().replace(searchQuote, replaceQuote));
        });

        jQuery('.SolidBreadCrumbCurrent').each(function () {
            jQuery(this).html(jQuery(this).html().replace(searchQuote, replaceQuote));
        });
    }

</script>
Reference:
Advertisements

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