In GatheringNodeData event I'm trying to collect the Urllink and add it to Index. To get the Url I need to get IPublishedContent object. To get that I've tried to us the UmbracoHelper.TypedContent.
![enter image description here][1]
Item is visible in the database
var person = umbracoHelper.TypedContent(nodeData.Fields["id"]);
UmbracoContext context;
if (UmbracoContext.Current == null)
{
var worker = new SimpleWorkerRequest("/", string.Empty, new StringWriter());
var httpContext = new HttpContext(worker);
var dummyContext = new HttpContextWrapper(httpContext);
context = UmbracoContext.EnsureContext(
dummyContext,
ApplicationContext.Current,
new WebSecurity(dummyContext, ApplicationContext.Current),
false);
}
else
{
context = UmbracoContext.Current;
}
var helper = new UmbracoHelper(context);
person = helper.TypedContent(nodeData.NodeId);
if (nodeData.Fields.ContainsKey("content") && nodeData.Fields.ContainsKey("id") && person != null)
Person is null.
This Document exists in database but doesn't exists in the umbraco.Config file, so I guess it is not in the Content cache.
I cannot use the ApplicationContext.Current.Services.ContentService.GetById(nodeData.NodeId), becuase I will not get the Url to the document.
What I'm doing wrong?
Can I get the Url in other way ?
The nodeData variable is of type : IndexingNodeDataEventArgs.
No I dont have property converter turned on.
How can I benefit from the property converter?
So my solution to this was using ContentService and used ToUrlSegment method as it seems that I don't need full url, but only current page url segment.
So I guess I could get rid of the ContentService method and just base on the nodeData variable.
UmbracoHelper.TypedContent returns null for new document in GetheringNodeData
I'm using Umbraco version 7.6.11.
In GatheringNodeData event I'm trying to collect the Urllink and add it to Index. To get the Url I need to get IPublishedContent object. To get that I've tried to us the UmbracoHelper.TypedContent. ![enter image description here][1]
Item is visible in the database
Person is null. This Document exists in database but doesn't exists in the umbraco.Config file, so I guess it is not in the Content cache.
I cannot use the ApplicationContext.Current.Services.ContentService.GetById(nodeData.NodeId), becuase I will not get the Url to the document.
What I'm doing wrong? Can I get the Url in other way ?
Hi Dawid
Try this one:
Alex
Hi Dawid,
Did you find a solution? Share with our community, please
/Alex
In your first line, what type of object is nodeData? Do you have property converters turned on?
The nodeData variable is of type : IndexingNodeDataEventArgs. No I dont have property converter turned on. How can I benefit from the property converter?
So my solution to this was using ContentService and used ToUrlSegment method as it seems that I don't need full url, but only current page url segment.
So I guess I could get rid of the ContentService method and just base on the nodeData variable.
is working on a reply...