Table of Contents

Class ContentAppIndexProvider

Namespace
Dynamicweb
Assembly
Dynamicweb.dll
The class ContentAppIndexProvider allows to extend indexing content paragraph with module specific fields or documents to be used with Query publisher app.
public abstract class ContentAppIndexProvider
Inheritance
ContentAppIndexProvider
Inherited Members

Examples

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]);
        }
    }
}

Fields

AppItemContent

The app item content const.
protected const string AppItemContent = "AppItemContent"

Field Value

string

Remarks

Used as field system name for index schema

AppItemId

The app item id const.
protected const string AppItemId = "AppItemId"

Field Value

string

Remarks

Used as field system name for index schema

AppItemTitle

The app item title const.
protected const string AppItemTitle = "AppItemTitle"

Field Value

string

Remarks

Used as field system name for index schema

AppSystemName

The app system name const.
public const string AppSystemName = "AppSystemName"

Field Value

string

Remarks

Used as field system name for index schema

Methods

CanHandle(string)

Returns value inicating whether current app index provider can handle the app by it's system name.
public abstract bool CanHandle(string appSystemName)

Parameters

appSystemName string
The app system name.

Returns

bool
Returns true if current app index provider can handle the app.

ExtendTemplate(Template, IDictionary)

Extends template with tags needed to render extended index fields.
public virtual void ExtendTemplate(Template template, IDictionary doc)

Parameters

template Template
The template to be rendered.
doc IDictionary
The document as IDictionary

GetAll()

Gets all the ContentAppIndexProvider instances.
public static IEnumerable<ContentAppIndexProvider> GetAll()

Returns

IEnumerable<ContentAppIndexProvider>
The collection of ContentAppIndexProvider.

GetDocuments(int, IndexDocument, DataRow)

Gets the index documents for specific paragraph.
public abstract IEnumerable<IndexDocument> GetDocuments(int pageId, IndexDocument pageDocument, DataRow appParagraphRow)

Parameters

pageId int
The page id.
pageDocument IndexDocument
The parent page index document.
appParagraphRow DataRow
The paragraph DataRow.

Returns

IEnumerable<IndexDocument>
The collection of IndexDocument.

GetFields()

Gets fields specific for current app index provider.
public virtual IEnumerable<FieldDefinitionBase> GetFields()

Returns

IEnumerable<FieldDefinitionBase>
The collection of FieldDefinitionBase.
To top