Skip to content

Instantly share code, notes, and snippets.

@leethomascook
Created September 21, 2016 08:21
Show Gist options
  • Save leethomascook/c30ec46bce9844a000cf5de81e958bcd to your computer and use it in GitHub Desktop.
Save leethomascook/c30ec46bce9844a000cf5de81e958bcd to your computer and use it in GitHub Desktop.
public class CustomUmbracoSearchResultCoverter : DefaultUmbracoSearchResultCoverter, IUmbracoSearchResultCoverter
{
public bool CanConvert(string contentAlias)
{
return contentAlias == "nameOfDocType";
}
public override string GetCategory(BaseUmbracoItem currentItem)
{
string category = "";
if (currentItem.Parent.Parent != null)
{
if (currentItem.Parent.Parent.TemplateId.ToLower() == "newslandingpage" ||
currentItem.Parent.Parent.TemplateId.ToLower() == "videolandingpage")
{
return currentItem.Parent.Name;
}
}
while (currentItem != null && currentItem.Parent != null && currentItem.Parent.Name != "Home")
{
category = currentItem.Parent.Title;
currentItem = currentItem.Parent;
}
return category;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment