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
How would I go about getting an IPublishedContent node without hard coding the id of the page?
I am making an AJAX call to update a partial view and lose Umbraco context, therefore I cannot use something like AssignedContentItem.
Basically I have the below:
IPublishedContent node = this.UmbracoContext.ContentCache.GetById(CurrentPage.Id);
var currentUser = Umbraco.MembershipHelper.GetCurrentMember(); var currentUserWelcome = node.GetProperty("profileWelcome") + currentUser.Name + "!"; var model = new Profile { WelcomeTitle = currentUserWelcome }; return PartialView(LAYOUT_DIRECTORY + "_YourProfile.cshtml");
I want to dynamically get the corresponding page so that if it were to move in the back office or the id were to change it would not break.
Thanks
I would just include the id in the request for your action.
public class SomethingSurfaceController{ public object YourProfile(int page){ var node = Umbraco.Content(page); [...] } }
HTH :)
So you are saying pass the page along as a parameter in my ActionResult Signature?
yes
use that page-parameter to find the node with your content
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Umbraco 8 get IPublishedContent node without hardcoding the id
How would I go about getting an IPublishedContent node without hard coding the id of the page?
I am making an AJAX call to update a partial view and lose Umbraco context, therefore I cannot use something like AssignedContentItem.
Basically I have the below:
IPublishedContent node = this.UmbracoContext.ContentCache.GetById(CurrentPage.Id);
I want to dynamically get the corresponding page so that if it were to move in the back office or the id were to change it would not break.
Thanks
I would just include the id in the request for your action.
HTH :)
So you are saying pass the page along as a parameter in my ActionResult Signature?
yes
use that page-parameter to find the node with your content
is working on a reply...