Class ContentAppIndexProvider
- Namespace
- Dynamicweb.Content
- 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.
- Inheritance
-
Content
App Index Provider
- 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.
Field Value
Remarks
Used as field system name for index schema
AppItemId
The app item id const.
Field Value
Remarks
Used as field system name for index schema
AppItemTitle
The app item title const.
Field Value
Remarks
Used as field system name for index schema
AppSystemName
The app system name const.
Field Value
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.
Parameters
appSystemName
stringThe 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.
Parameters
template
TemplateThe template to be rendered.
doc
IDictionaryThe document as IDictionary
GetAll()
Gets all the ContentAppIndexProvider instances.
Returns
- IEnumerable<Content
App >Index Provider The collection of Content
App .Index Provider
GetDocuments(int, IndexDocument, DataRow)
Gets the index documents for specific paragraph.
public abstract IEnumerable<IndexDocument> GetDocuments(int pageId, IndexDocument pageDocument, DataRow appParagraphRow)
Parameters
pageId
intThe page id.
pageDocument
IndexDocument The parent page index document.
appParagraphRow
DataRow The paragraph Data
Row .
Returns
- IEnumerable<Index
Document > The collection of Index
Document .
GetFields()
Gets fields specific for current app index provider.
Returns
- IEnumerable<Field
Definition >Base The collection of Field
Definition .Base