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 need a way to get content not by id but by alias?
In UmbracoApiController I have a method for this: GetNodeByAlias(alias);
How can this be accomplished from the Umbraco context?
Hi Dennis,
You could use an XPath expression with the UmbracoHelper:
UmbracoHelper umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
If there are multiple content nodes with the given alias:
IEnumerable<IPublishedContent> content = umbracoHelper.TypedContentAtXPath("//" + alias);
Or if you are expecting a single result you can use:
IPublishedContent content = umbracoHelper.TypedContentSingleAtXPath("//" + alias);
HTH, Hendy
Thank you Hendry, that solved my problem :)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Get Content by alias
I need a way to get content not by id but by alias?
In UmbracoApiController I have a method for this: GetNodeByAlias(alias);
How can this be accomplished from the Umbraco context?
Hi Dennis,
You could use an XPath expression with the UmbracoHelper:
If there are multiple content nodes with the given alias:
Or if you are expecting a single result you can use:
HTH, Hendy
Thank you Hendry, that solved my problem :)
is working on a reply...