Register pipe templates

You can define template for your pipe.

There are two template types:

  • SearchItemTemplate - for creating a search index.
  • PublishingItemTemplate - for creating a publishing point.

To register a template for a pipe, you use the RegisterTemplatePipe method:

C#
using System.Collections.Generic;
using Telerik.Sitefinity.Publishing;
using Telerik.Sitefinity.Publishing.Model;
using Telerik.Sitefinity.Publishing.Pipes;
using Telerik.Sitefinity.Publishing.Translators;

namespace SitefinityWebApp
{
   public class RegisterPipeTemplates
   {
       // <summary>
       /// Registers pipe templates.
       /// There are two template types:
       ///     - SearchItemTemplate - for search index publishing point
       ///     - PublishingItemTemplate - for default publishing point
       /// </summary>
       public static void RegisterThePipeTemplates()
       {
           // Get the default pipe settings. For custom pipe use MyPipe.GetTemplatePipeSettings()
           PipeSettings defaultContentInboundPipeSettings = ContentInboundPipe.GetTemplatePipeSettings();

           // To register a template for a pipe, use the RegisterTemplatePipe method
           // The template is part of the settings. With registering the SearchItemTemplate, we add the inbound pipe as an option when creating a search index.
           PublishingSystemFactory.RegisterTemplatePipe("SearchItemTemplate", defaultContentInboundPipeSettings);
       }

       public static List<Mapping> CreateCustomMappings()
       {
           List<Mapping> mappingsList = new List<Mapping>();

           var contentMapping =
               new Mapping()
               {
                   DestinationPropertyName = "Content",
                   IsRequired = true,
                   SourcePropertyNames = new[] { "Title" }
               };

           mappingsList.Add(contentMapping);

           var linkMapping =
               new Mapping()
               {
                   DestinationPropertyName = "Link",
                   IsRequired = true,
                   SourcePropertyNames = new[] { "Link" }
               };

           linkMapping.Translations.Add(new PipeMappingTranslation() { TranslatorName = UrlShortenerTranslator.TranslatorName });

           mappingsList.Add(linkMapping);

           return mappingsList;
       }
   }
}

The template is part of the settings. With registering the SearchItemTemplate, you add your inbound custom pipe as an option when creating a search index.

Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
New to Sitefinity?