Hey guys I have been away for a while, the last time I was using umbraco I was using version 4.
I am currently using version 6 and can't find the methods in the API to get particular nodes and query there properties. According to the back office of umbraco I am using - Umbraco v6.2.1
After a bit of googling and reading I have found that uQuery has been put in to the umbraco core and this is the object I need.
However, even though I have this using statement.
using umbraco;
I can't access uqery, its not in that name space, I have also tried
using umbraco.NodeFactory
but the NodeFactory is also not in the Umbraco name space.
What I have found is:
ContentService
so if I do something like this:
var childnodes = contentService.GetChildren(1503);
how do I count the number of nodes? ie
childnodes.count is not valid
Also how do I loop through the items and see what values are set for a given property?
When I do Umbraco. the only option I get is CORE.. so Umbraco.Core
so there is no Umbraco.TypedContent or Umbraco.Core.TypedContent
Just checked and I am using a separate class library project I have a reference to Umbraco.Core but not to Umbraco,
Do I need to add an assembly reference to this? In my CMS project (ie the umbraco website project) there is a Umbraco.dll file with file version 1.0.5261.29001
I have found the TypedContent method now... but I can only get the nodes by ID.. I want to get it by type and name... if I can so that I don't have to worry about someone deleting/recreating the node with a different ID
It might be easier to just store the id in the web.config as an app setting. If someone deletes/recreate it you just have to update the id in the app setting. Another option is to select the node with a content picker on the top node and get that id. Finally if you want to find a specific node you could get the root node and query all Descendants with a where statement in which you search for the name and type.
Umbraco 6 - Basic Content node navigation.
Hey guys I have been away for a while, the last time I was using umbraco I was using version 4.
I am currently using version 6 and can't find the methods in the API to get particular nodes and query there properties. According to the back office of umbraco I am using - Umbraco v6.2.1
After a bit of googling and reading I have found that uQuery has been put in to the umbraco core and this is the object I need. However, even though I have this using statement.
using umbraco;
I can't access uqery, its not in that name space, I have also tried
using umbraco.NodeFactory
but the NodeFactory is also not in the Umbraco name space.
What I have found is:
ContentService
so if I do something like this:
var childnodes = contentService.GetChildren(1503);
how do I count the number of nodes? ie
childnodes.count is not valid
Also how do I loop through the items and see what values are set for a given property?
Hello,
You should use the Umbraco helper for this. With that it's possible to do this:
More info: http://our.umbraco.org/documentation/Reference/Mvc/querying
Jeroen
Thanks for your quick reply Jeroen
When I do Umbraco. the only option I get is CORE.. so Umbraco.Core
so there is no Umbraco.TypedContent or Umbraco.Core.TypedContent
Just checked and I am using a separate class library project I have a reference to Umbraco.Core but not to Umbraco,
Do I need to add an assembly reference to this? In my CMS project (ie the umbraco website project) there is a Umbraco.dll file with file version 1.0.5261.29001
Do I need to reference this?
Hello,
You can create your own helper like this:
It might be good to add the Umbraco.Core dll and add that namespace for a lot of good extension methods.
Jeroen
I have found the TypedContent method now... but I can only get the nodes by ID.. I want to get it by type and name... if I can so that I don't have to worry about someone deleting/recreating the node with a different ID
Any ideas?
It might be easier to just store the id in the web.config as an app setting. If someone deletes/recreate it you just have to update the id in the app setting. Another option is to select the node with a content picker on the top node and get that id. Finally if you want to find a specific node you could get the root node and query all Descendants with a where statement in which you search for the name and type.
Jeroen
is working on a reply...