Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have children and picked nodes that render as part of a parent page.
Is there a way to extend the ExternalIndexer so picked or child nodes are indexed into the same record as the parent?
use gathering node data event and for the current item get its children and any picked nodes then get them and inject their content into the fields property for the current item being indexed.
Thanks for the pointer Ismail,
We have a lot of Factories to create viewModels, I'd like to re-use these to generate indexable content... however they all rely on Umbraco.Context, which is not present when indexing.
The most common issue is any call to GetPropertyValue<string>(...) will fail when it hits Umbraco.Web.Templates.TemplateUtilities.ParseInternalLinks
But I'm guessing macros will fail also.
Is there a way around this?
Create a fake UmbracoContext?
currently, my factory has ugly if statements like this:
if (UmbracoContext.Current == null)
viewModel = new ExpandCollapse
Heading = nestedContent.GetProperty("heading")?.DataValue.ToString(),
// snip //
viewModel = nestedContent.Map<T>(); // using https://github.com/AndyButland/UmbracoMapper
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
var helper = new UmbracoHelper(UmbracoContext.Current);
+= (sender, e) => Indexer_GatheringNodeData(sender, e, helper);
void ExamineEvents_GatheringNodeData(object sender, IndexingNodeDataEventArgs e, UmbracoHelper helper)
//check if this is 'Content' (as opposed to media, etc...)
if (e.IndexType == IndexTypes.Content)
var page = helper.TypedContent(e.NodeId);
var title = page.GetPropertyValue<string>("title");
// NullReferenceException in "Umbraco.Web.Templates.TemplateUtilities.ParseInternalLinks"
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted