+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / SiteFinity 6.3 unable to create Site Index based on node

SiteFinity 6.3 unable to create Site Index based on node

2 posts, 0 answered
  1. Cary
    Cary avatar
    2 posts
    Registered:
    18 Nov 2010
    27 Feb 2014
    Link to this post

    Migrated a 3.7SP4 site to 6.3. Now trying to create site indexes and I had one in 3.7SP4 that was based on a Node. I do not see this in 6.3. Is it no longer available? Is there something that replaces it?

    Thank you

  2. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    Registered:
    02 Dec 2016
    07 Mar 2014
    Link to this post
    Hi Cary,

    Currently we do not provide an option to specify which pages the search index should be applied to. You can extend the current functionality and create a search index that applies only to a selection of pages by replacing the default PageInboundPipe with a custom one.

    To do this, you need to create a class in you project that inherits from the default PageInboundPipe and to override the PushData method. In this method we will take only the pages under the group page titled "GroupPage" and then pass them to the base PushData() method, which will index only the pages under the selected group page: 

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Sitefinity.Publishing.Pipes;
    using Telerik.Sitefinity.Modules.Pages;
    using Telerik.Sitefinity.Publishing;
    using Telerik.Sitefinity;
    using Telerik.Sitefinity.Publishing.Model;
    using Telerik.Sitefinity.Pages.Model;
     
    namespace SitefinityWebApp
    {
        public class PageInboundPipeCustom : PageInboundPipe
        {
            public override void PushData(IList<Telerik.Sitefinity.Publishing.PublishingSystemEventInfo> items)
            {
                List<Telerik.Sitefinity.Publishing.PublishingSystemEventInfo> myItems = new List<Telerik.Sitefinity.Publishing.PublishingSystemEventInfo>();
     
                foreach (var item in items)
                {
                    PageNode node = null;
     
                    if (item.Item is WrapperObject && ((WrapperObject)item.Item).WrappedObject != null)
                    {
                        node = (PageNode)((WrapperObject)item.Item).WrappedObject;
                    }
                    else
                    {
                        node = ((PageNode)item.Item);
                    }
     
                    if (node.Page != null && node.Page.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
                    {
                        while (true)
                        {
                            node = node.Parent;
     
                            if (node.Title == "GroupPage")
                            {
                                // this will index only one page node with its children,
                                // don`t add items here for the pages that shouldn`t be indexed
                                myItems.Add(item);
                                break;
                            }
     
                            if (node.Parent == null)
                            {
                                break;
                            }
                        }
                    }
                }
     
                base.PushData(myItems);
            }
        }
    }

    Now, we should replace the default pipe with the custom one in the Global.asax file by unregistering the default pipe and registering the custom one:

    protected void Application_Start(object sender, EventArgs e)
    {
        Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += Bootstrapper_Initialized;
    }
     
    void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
    {
        if (e.CommandName == "Bootstrapped")
        {                
            PublishingSystemFactory.UnregisterPipe(PageInboundPipe.PipeName);
        PublishingSystemFactory.RegisterPipe(PageInboundPipeCustom.PipeName, typeof(PageInboundPipeCustom));
        }
    }

    After performing the above, the newly created search indexes will use the new custom pipe for pages.

    Regards,
    Sabrie Nedzhip
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
2 posts, 0 answered