Click or drag to resize

ContentAppIndexProvider Class

The class ContentAppIndexProvider allows to extend indexing content paragraph with module specific fields or documents to be used with Query publisher app.
Inheritance Hierarchy

Namespace:  Dynamicweb
Assembly:  Dynamicweb (in Dynamicweb.dll) Version: 9.10.0
public abstract class ContentAppIndexProvider

The ContentAppIndexProvider type exposes the following members.

Protected methodContentAppIndexProvider
Initializes a new instance of the ContentAppIndexProvider class
Public methodCanHandle
Returns value inicating whether current app index provider can handle the app by it's system name.
Public methodExtendTemplate
Extends template with tags needed to render extended index fields.
Public methodStatic memberGetAll
Gets all the ContentAppIndexProvider instances.
Public methodGetDocuments
Public methodGetFields
Gets fields specific for current app index provider.
Protected fieldStatic memberAppItemContent
The app item content const.
Protected fieldStatic memberAppItemId
The app item id const.
Protected fieldStatic memberAppItemTitle
The app item title const.
Public fieldStatic memberAppSystemName
The app system name const.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Dynamicweb.Indexing;
using Dynamicweb.Indexing.Schemas;
using Dynamicweb.Rendering;

namespace Dynamicweb.Examples.Content
    public class ContentAppIndexProviderSample : ContentAppIndexProvider
        public override bool CanHandle(string appSystemName)
            return "MyModule".Equals(appSystemName, StringComparison.OrdinalIgnoreCase);
        public override IEnumerable<FieldDefinitionBase> GetFields()
            //get fields from base class
            var fields = base.GetFields().ToList();

            //add an extra field
            fields.Add(new FieldDefinition()
                Name = "MyModuleExtraField1",
                SystemName = "MyModuleExtraField1",
                Source = "MyFieldDbColumnName",
                TypeName = "System.String",
                Analyzed = false,
                Indexed = true,
                Stored = true
            return fields;

        public override IEnumerable<IndexDocument> GetDocuments(int pageId, IndexDocument pageDocument, DataRow appParagraphRow)
            for (var i = 0; i < 2; i++)
                var myModuleDoc = new IndexDocument();
                //copy all the page document values
                pageDocument.ToList().ForEach(x => myModuleDoc.Add(x.Key, x.Value));
                //add app system name
                myModuleDoc.Add(AppSystemName, "MyModule");
                //add app item id to 
                myModuleDoc.Add(AppItemId, i.ToString());
                //add extra content
                myModuleDoc.Add(AppItemContent, "My module extra content" + i);

                yield return myModuleDoc;

        public override void ExtendTemplate(Template template, IDictionary doc)
            //let base class extend template
            base.ExtendTemplate(template, doc);

            //Set tag with extended value
            template.SetTagValue("MyModule:ExtraContent", doc[AppItemContent]);
See Also