I am trying to retrieve nodeId by document type with no success , I have tried the following code but none of them works , what i need to do, is to display children of node whose parent document type is folder, also i have got 2 languages , below is the tree of my content nodes:
-EN
--Contact
--Products[document type = folder]
---Product1[document type = folder1]
---Product2[document type = folder2]
--Information
-ES
--Contact
--Products[document type = folder]
---Product1[document type = folder1]
---Product2[document type = folder2]
--Information
Now the problem is I cant use fixed node to display number of products as it wont accross multi language so i have to use it dynamically to get the node id of particular type and then get the children of that doucment type and display in respective language.
Below is the code i tried with no success:
var parent = @Umbraco.TypedContent(1206);//wont work for multi languages as id is fixed
var locationNodes =Model.AncestorOrSelf(1).Descendants("Folder");
// Get root node:
var root = Model.AncestorOrSelf(1);
// Get all descendants, filter by type:
var nodes = root.Descendants("Folder");
var test = Model.DescendantsOrSelf("Folder");
var anotherTest = Model.DescendantsOrSelf(1).Where(n => n.DocumentTypeAlias == "Folder");
var productNodes = @Model.AncestorOrSelf(1).Descendants("FolderFabric");
None of the above works apart from fixed id one , any suggestions or any assistance will be appreciated
Hi, looks like you are using a partial view, what Model are you passing to it?
I think that var locationNodes = Model.AncestorOrSelf(1).Descendants("Folder"); should work just fine assuming your model is the current page of IPublishedContent
Get NodeId by Document Type in Umbraco 6
Hi ,
I am trying to retrieve nodeId by document type with no success , I have tried the following code but none of them works , what i need to do, is to display children of node whose parent document type is folder, also i have got 2 languages , below is the tree of my content nodes:
-EN
--Contact
--Products[document type = folder]
---Product1[document type = folder1]
---Product2[document type = folder2]
--Information
-ES
--Contact
--Products[document type = folder]
---Product1[document type = folder1]
---Product2[document type = folder2]
--Information
Now the problem is I cant use fixed node to display number of products as it wont accross multi language so i have to use it dynamically to get the node id of particular type and then get the children of that doucment type and display in respective language.
Below is the code i tried with no success:
None of the above works apart from fixed id one , any suggestions or any assistance will be appreciated
Thanks
Hi, looks like you are using a partial view, what Model are you passing to it?
I think that
var locationNodes = Model.AncestorOrSelf(1).Descendants("Folder");
should work just fine assuming your model is the current page of IPublishedContentOh, one thing to check is the capitalization of your document type alias, is it "Folder" or "folder"
Yes i am using the partial view passing
and call the partial view
And i have rechecked the alias.
Ok, I just this little snippet a test and it works with the structure you have described:
The above code is working. Tried your code which is also working thanks
Ah cool, it's a good idea to do the Any() check just in case a site doesn't yet have a "Folder", otherwise the First() would YSOD.
is working on a reply...