How to get a content node using Umbraco 5 API

1.1k Views Asked by At

I'm an Umbraco newbie and trying to get up to speed. One of the things i'm trying out is the API and accessing a node in the content tree. Unfortunately documentation is a bit thin and i can't find any info covering such a basic task...

I've got a simple content structure

Content > Home > About

How do i retrieve the About node using C# and the API from a plain old model class?

In other CMS's it would be as simple as calling Database.GetItem("/content/home/about")

How is this achieved with Umbraco v5?

Thanks

1

There are 1 best solutions below

3
On

If you have a single, specific piece of content you want to get it, you can select it using the hiveid like so:

 Umbraco.GetContentById("content://p__nhibernate/v__guid/0000000000000000")

You can find your content id by examining the content's properties from the backoffice.

EDIT:

If you truly must get the content by uri, you could do so by querying the hive. I can't recommend it for performance though.

_context.Application.Hive.QueryContent().Where(x => x.NiceUrl().Equals("/faq/functionality/submit-a-question",StringComparison.InvariantCultureIgnoreCase);