Exclude RADmenu nav from SharePoint Search

6 posts, 0 answers
  1. Chuck
    Chuck avatar
    3 posts
    Member since:
    Mar 2011

    Posted 21 May 2012 Link to this post

    We have found that the items list in our RADmenu top navigation for SharePoint 2010 are being indexed on every page by the SharePoint search. This makes it difficult to find a meaningful search result as many terms show up on every page in our site.
    We have found an article on this topic

    http://www.matdesmarais.com/2011/12/sharepoint-2010-excluding-navigation-nodes-from-search-crawl/  , which refers to including NOINDEX in the navigation items.

    Is there a way to set our master page using RADmenu to insert the NOINDEX in all of the DIVs associate with the menu navigation?


  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 22 May 2012 Link to this post

    Hi Chuck,

    You can set the CssClass property for the menu and for the items:
    <telerik:RadMenu ID="RadMenu1" runat="server" CssClass="noindex"
           onitemdatabound="RadMenu1_ItemDataBound">
           <Items>
               <telerik:RadMenuItem runat="server" Text="Root RadMenuItem1">
                   <Items>
                       <telerik:RadMenuItem runat="server" Text="this" CssClass="noindex">
                       </telerik:RadMenuItem>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 2">
                       </telerik:RadMenuItem>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 3">
                       </telerik:RadMenuItem>
                   </Items>
               </telerik:RadMenuItem>
               <telerik:RadMenuItem runat="server" Text="Root RadMenuItem2">
               </telerik:RadMenuItem>
               <telerik:RadMenuItem runat="server" Text="Root RadMenuItem3">
               </telerik:RadMenuItem>
           </Items>
       </telerik:RadMenu>

    If the menu is databound, then you can use ItemDataBound:
    protected void RadMenu1_ItemDataBound(object sender, Telerik.Web.UI.RadMenuEventArgs e)
       {
           e.Item.CssClass = "noindex";
       }


    Kind regards,
    Peter
    the Telerik team
    Learn how the Telerik controls can be integrated in SharePoint 2007/2010 from this resource. To watch them in action, explore our online SharePoint 2010 demo site.

  3. Chuck
    Chuck avatar
    3 posts
    Member since:
    Mar 2011

    Posted 25 May 2012 Link to this post

    is there a similar approach that would allow us to set the noindex on the section
    <div class="rmSlide">

    so that the end result was <div class="rmSlide noindex">

  4. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 30 May 2012 Link to this post

    Hi,

    You can use jQuery to add the 'noindex' class to any elements you need to. For example:
    <script type="text/javascript">
           function OnClientLoad(sender) {
     
               var $ = $telerik.$;
     
               $(sender.get_element()).addClass("noindex");
               $(".rmSlide").addClass("noindex");
               $(".rmText").addClass("noindex");
               $(".RadSiteMap").addClass("noindex");
     
           }
       </script>
       <telerik:RadMenu ID="RadMenu1" Skin="Sitefinity" runat="server" OnDataBound="RadMenu1_DataBound"
           OnClientLoad="OnClientLoad">
       </telerik:RadMenu>


    All the best,
    Peter
    the Telerik team
    Learn how the Telerik controls can be integrated in SharePoint 2007/2010 from this resource. To watch them in action, explore our online SharePoint 2010 demo site.
  5. Chuck
    Chuck avatar
    3 posts
    Member since:
    Mar 2011

    Posted 30 May 2012 Link to this post

    Thanks for the suggestion, but the Microsoft search engine will not process the jQuery script and so will not see the noindex class. Our goal is to exclude the global naviagation DIVS from the SharePoint search and to do so requires inserting the noindex class  on each DIV and every DIV to be exclude before if it is sent to the client.
  6. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 05 Jun 2012 Link to this post

    Hello Chuck,

    In that case, you will have to override the rendering of the controls involved in your navigation system. . For example, for RadMenu you can do the following:
    public class CustomRadMenu: RadMenu
    {
        protected override string CssClassFormatString
        {
            get
            {
                string formatString = "RadMenu RadMenu_{0} noindex";
     
                if (Attributes["dir"] == "rtl")
                {
                    formatString += " RadMenu_rtl RadMenu_{0}_rtl noindex";
                }
     
                if (!Width.IsEmpty || !Height.IsEmpty)
                {
                    formatString += " rmSized";
                }
     
                return formatString;
            }
        }
    }

    protected void Page_Load(object sender, EventArgs e)
       {
           CustomRadMenu myMenu = new CustomRadMenu();
           RadMenuItem rootItem = new RadMenuItem("root 1");
           rootItem.Items.Add(new RadMenuItem("child 1"));
           myMenu.Items.Add(rootItem);
           Page.Form.Controls.Add(myMenu);
       }


    Kind regards,
    Peter
    the Telerik team
    Learn how the Telerik controls can be integrated in SharePoint 2007/2010 from this resource. To watch them in action, explore our online SharePoint 2010 demo site.
Back to Top