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 just upgraded a project from v. 4.9.0 to v.6.1.x. I am trying to fix the differences in the API, but I have difficulties to something as simple as the current node in a master-page. I have looked in the documentation, but it seem...ummm how to put it, lacking ;)
I have looked at Umbraco.Core.ApplicationContext.Current.Services.ContentService but I can't seem to find anything which will return the current node?
Where are you trying to load the current node? I believe that in a razor script, you can use CurrentPage to get the current node.
It was in a master-page and not a Razor file.
I just saw that I could still use umbraco.NodeFactory.Node.GetCurrent() (There was an error, which I mistakenly thought was this line). It just feels wrong to use the old NodeFactory, when there is the new ContentService API.
I believe it is still possible - but probably deprecated. Personally, I always wrap something special in a Macro. If you would wrap it in a Macro, you would get to use the provided property "CurrentPage" or "Model" to access the current Node. I'm sure one of those two will work.
I seems like you basically don't have the current context from outside of a macro, masterpage, usercontrol etc.
If you don't have access to the current node you can do that with the new API :
Umbraco.Web.UmbracoHelper umbracoHelper = new Umbraco.Web.UmbracoHelper(UmbracoContext.Current);
and "umbracoHelper.AssignedContentItem" is your current node as a IPublishedContent
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted