I think it depends on where you're running this code.
Inside a View or Partial, you could use:
var content = Umbraco.TypedContent(id);
This returns IPublishedContent, so you can do things like content.GetProperty("alias")
You can also use the "dynamic" way:
var content = Umbraco.Content(1234)
Then you can do things like content.alias. The first way is probably recommended and faster, though. There's a little bit of info on both of these methods here: Querying
There's also the ContentService, which has a .GetById() method you can use. This returns a Content object which has its own methods for property access. At the moment I'm not exactly sure if this is meant to be used on the front-end or not, though.
Get Node in Umbraco 6 - new Node? Best Way?
Hi I was just wondering the best way to get a node by ID in umbraco 6 new Node(id) doesn't work. Just wondering what people were using
Also where is all the latest api documentation.. the stuff linking off the website is horribly out of date including the examples!
something like new Node(1111).ChildrenAsList.Where(c => c.NodeTypeAlias == "someAlias"); no longer works
is that still best practice for querying.. the documentation above doesn't have any examples.
Depends on which interface you required.For just reading properties I prefer
I think it depends on where you're running this code.
Inside a View or Partial, you could use:
This returns IPublishedContent, so you can do things like content.GetProperty("alias")
You can also use the "dynamic" way:
Then you can do things like content.alias. The first way is probably recommended and faster, though. There's a little bit of info on both of these methods here: Querying
There's also the ContentService, which has a .GetById() method you can use. This returns a Content object which has its own methods for property access. At the moment I'm not exactly sure if this is meant to be used on the front-end or not, though.
hi Tom,
Great article :
http://umbraco.com/follow-us/blog-archive/2013/1/22/introducing-contentservice-aka-the-v6-api.aspx
Thanks, Alex
Hello,
The content service is to fetch the data from the database instead of the xml cache.
It's better to use IPublishedContent:
http://our.umbraco.org/documentation/Reference/Mvc/querying
http://umbraco.com/follow-us/blog-archive/2012/10/30/getting-started-with-mvc-in-umbraco-410.aspx
Jeroen
Hi Jeroen )
What about working in services and api's ?
Thanks, Alex
Some replies were hidden so my post might be confusing: https://twitter.com/cultiv/status/431399442227281920
What would you like to know?
Jeroen
is working on a reply...