Skip to content

Commit

Permalink
updated readme example to include the Umbraco event
Browse files Browse the repository at this point in the history
  • Loading branch information
Hendy committed Oct 9, 2018
1 parent d99e804 commit 495f3ef
Showing 1 changed file with 58 additions and 45 deletions.
103 changes: 58 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,66 +18,79 @@ To configure indexing there are static methods on the Our.Umbraco.Look.Services.
Eg.

using Our.Umbraco.Look.Services;

LookIndexService.SetNameIndexer(publishedContent => {
using Umbraco.Core;

if (publishedContent.DocumentTypeAlias == "myDocTypeAlias")
{
// return a string (or null)
return "my custom name for myDocTypeAlias to be indexed";
}
public class ConfigureIndexing : ApplicationEventHandler
{
protected override void ApplicationStarted(
UmbracoApplicationBase umbracoApplication,
ApplicationContext applicationContext)
{
LookIndexService.SetNameIndexer(publishedContent => {

if (publishedContent.DocumentTypeAlias == "myDocTypeAlias")
{
// return a string (or null)
return "my custom name for myDocTypeAlias to be indexed";
}

// fallback to default indexing (or can return null)
return LookIndexService.DefaultNameIndexer(publishedContent);
});
// fallback to default indexing (or can return null)
return LookIndexService.DefaultNameIndexer(publishedContent);
});

LookIndexService.SetTextIndexer(publishedContent => {
LookIndexService.SetTextIndexer(publishedContent => {

if (publishedContent.DocumentTypeAlias == "myDocTypeAlias")
{
// return a string (or null)
return "my text for myDocTypeAlias to be indexed";
}
if (publishedContent.DocumentTypeAlias == "myDocTypeAlias")
{
// return a string (or null)
return "my text for myDocTypeAlias to be indexed";
}

// fallback to default indexing (or can return null)
return LookIndexService.DefaultTextIndexer(publishedContent);
});
// fallback to default indexing (or can return null)
return LookIndexService.DefaultTextIndexer(publishedContent);
});

LookIndexService.SetTagIndexer(publishedContent => {
LookIndexService.SetTagIndexer(publishedContent => {

if (publishedContent.DocumentTypeAlias == "myDocTypeAlias")
{
// return a string array (or null)
return new string[] { "tag1", "tag2" };
}
if (publishedContent.DocumentTypeAlias == "myDocTypeAlias")
{
// return a string array (or null)
return new string[] { "tag1", "tag2" };
}
// fallback to default indexing (or can return null)
return LookIndexService.DefaultTagIndexer(publishedContent);
});
// fallback to default indexing (or can return null)
return LookIndexService.DefaultTagIndexer(publishedContent);
});

LookIndexService.SetDateIndexer(publishedContent => {
LookIndexService.SetDateIndexer(publishedContent => {

if (publishedContent.DocumentTypeAlias == "myDocTypeAlias")
{
// return a DateTime obj (or null)
return new DateTime(2005, 02, 16);
}
if (publishedContent.DocumentTypeAlias == "myDocTypeAlias")
{
// return a DateTime obj (or null)
return new DateTime(2005, 02, 16);
}

// fallback to default indexing (or can return null)
return LookIndexService.DefaultDateIndexer(publishedContent);
});
// fallback to default indexing (or can return null)
return LookIndexService.DefaultDateIndexer(publishedContent);
});

LookIndexService.SetLocationIndexer(publishedContent => {
LookIndexService.SetLocationIndexer(publishedContent => {

if (publishedContent.DocumentTypeAlias == "myDocTypeAlias")
{
// return an Our.Umbraco.Look.Models.Location obj (or null)
return new Lcoation(55.406330, 10.388500);
}

// currenty there is no default fallback
return null;
});



if (publishedContent.DocumentTypeAlias == "myDocTypeAlias")
{
// return an Our.Umbraco.Look.Models.Location obj (or null)
return new Lcoation(55.406330, 10.388500);
}
}

// currenty there is no default fallback
return null;
});

## Searching

Expand Down

0 comments on commit 495f3ef

Please sign in to comment.