Hey there!
I have a content picker in my Doc Type that is in a property that is a Nested Content Data Type.
It would be great to have the title for the list item use the name of the node the content picker is referring to rather than the node id.
Has anyone done this?
To get this value within the loop of a Nested Content Data Type you'll end up with something like this (not tested):
var nestedContentItems = Model.GetPropertyValue<IEnumerable<IPublishedContent>>("myPropertyAlias")
foreach(var item in nestedContentItems) {
var contentPickerNode = Umbraco.TypedContent(item.GetPropertyValue<int>("contentPicker"));
<li>@contentPickerNode.Name</li>
}
Oh. Thankyou for the reply. However, I am actually referring to the display of Nested Content Items in the CMS itself. Render the views is a snap. I love razor.
I reference the content picker property in the dynamic title property of the nested content and get the id back in the cms display.
i'm hoping to get the Name of the Node rather than the Id of the Node.
name of node in title instead of node id
Hey there! I have a content picker in my Doc Type that is in a property that is a Nested Content Data Type. It would be great to have the title for the list item use the name of the node the content picker is referring to rather than the node id. Has anyone done this?
Hi Ben,
I'm assuming your question refers to the displaying in the views, not the display of the list item in the CMS itself.
See the documentation of the Content Picker. I think the code example at the bottom does exactly what you want, am I right?
https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/Content-Picker
To get this value within the loop of a Nested Content Data Type you'll end up with something like this (not tested):
Oh. Thankyou for the reply. However, I am actually referring to the display of Nested Content Items in the CMS itself. Render the views is a snap. I love razor.
I reference the content picker property in the dynamic title property of the nested content and get the id back in the cms display.
i'm hoping to get the Name of the Node rather than the Id of the Node.
I was afraid that would be the answer ;-)
Can't help you there, sorry...
Ben:
Any luck figuring this out? I'm trying to do the same.
FYI - Related threads with more recent info:
https://our.umbraco.org/projects/backoffice-extensions/nested-content/nested-content-feedback/78386-label-for-multinode-tree-picker-for-nested-content
https://our.umbraco.org/projects/backoffice-extensions/nested-content/nested-content-feedback/81260-name-template-show-name-instead-of-id
is working on a reply...