Custom Search in Sitefinity 4.1.1574.0 Using Custom Pipes

Posted by Community Admin on 03-Aug-2018 05:36

Custom Search in Sitefinity 4.1.1574.0 Using Custom Pipes

All Replies

Posted by Community Admin on 16-Apr-2013 00:00

Hi,
I want to update the Search Result template to display the Description from Page Title & Properties tinyurl.com/celydrf. If there is no Description set for the page only then display the description from Body Copy of the page.

More details of required functionality are given in points below

  • if the page have the Description and the search keyword is present in the Description then Only Show the Page Description text in the Search Result.       
  • if the page have the Description and the search keyword is NOT present in the Description but present in the Body Copy then Only Show the Body Copy in the Search Result.       
  • If the page does not have any Description and the search keyword is present in the Body Copy then Only Show the Body Copy in the Search Result

I looked into http://www.sitefinity.com/blogs/ivanpelovski/posts/ivan-pelovskis-blog/2011/08/16/registering_custom_pipes_in_sitefinity for this functionality but it supports version from 4.2 and higher.

Website is build on Sitefinity  4.1.1574.0.

Please let me know how can I achieve this functionality or is it possible from Custom pipes?

Thanks,

Posted by Community Admin on 18-Apr-2013 00:00

Hi Waqar,

Actually, adding the the Description field to the search result can be done by replacing the default PageInboundPipe with a custom one. What practically has to be done is to create a class in your project, that inherits from PageInboundPipe and override the SetWrapperObjectProperties method. In it we'll add the Description property of the page as a value for the Summary property of the wrapped object:

namespace SitefinityWebApp
    public class CustomInboundPipe : PageInboundPipe
    
        protected override void SetWrapperObjectProperties(Telerik.Sitefinity.Publishing.WrapperObject wrapperObject, Telerik.Sitefinity.Pages.Model.PageNode node)
        
            base.SetWrapperObjectProperties(wrapperObject, node);
            if (!wrapperObject.HasProperty(PublishingConstants.FieldSummary))
                wrapperObject.AddProperty(PublishingConstants.FieldSummary, node.Page.Description.ToString());
        
    

Now, the default pipe should be replaced with a custom one in the Global.asax file of your project. On applicationStart we unregister the default pipe and register our custom pipe:

    public class Global : System.Web.HttpApplication
    
  
        protected void Application_Start(object sender, EventArgs e)
        
            Bootstrapper.Initialized -= Bootstrapper_Initialized;
            Bootstrapper.Initialized += Bootstrapper_Initialized;
        
  
        void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs args)
        
            if (args.CommandName == "Bootstrapped")
            
                ReplacePagePipeWithCustomPagePipe();
            
        
  
        private void ReplacePagePipeWithCustomPagePipe()
        
            //Remove the default page pipe
            PublishingSystemFactory.UnregisterPipe(PageInboundPipe.PipeName);
  
            //This code will add the PagePipeNoIndex to the registered pipes with the original page pipe name
            //so when the publishing system try's to use the page pipe will use the new one
            PublishingSystemFactory.RegisterPipe(PageInboundPipe.PipeName, typeof(CustomInboundPipe));
        
What is left is to go to the search index and in the Additional fields for search add the Description field. Then in the SearchResults widget's designer add the Description field to the corresponfing fields from the attached image (SearchResults1). Make sure to restart the application once you add the new pipe and Reindex after you add the Description field to the Additional fields for search.

Kind regards,
Jen Peleva
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items

This thread is closed