I am rather new to Umbraco and very excited about this well-built cms. Wow.
I am looking for advice on how to query for the element data types. I found many examples for querying content node data, but it does not work for element types.
Example:
I defined an element data type "car" which can be used in nested control property editors on several pages.
I have 2 different questions:
On a page MyCars with a nested content control cars which can
have items of data type car, how do I query for all car items on
that page?
How can I find all car items in any nested content control on any page underneath a specific page (all descendant content nodes), which the least performance hit?
I would be very grateful for a hint into the right direction.
Rendering a nested content is easy, you need to use something like this:
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@{
var items = Model.Value<IEnumerable<IPublishedElement>>("cars");
foreach(var item in items)
{
// Render your content, e.g. item.Value<string>("heading")
}
}
first let me say that it is amazing how much I can feel and perceive the remarkable friendliness of the Umbraco community, both here in the forum and also elsewhere when I read from and interact with people contributing to Umbraco. In a way, this makes me want to contribute as well, both as a programmer and as a human being, so to speak.
Thank you for your input. Somehow I missed this part of the docs.
As far as my second question goes, I am still unclear. I am experimenting and will come back with another followup question (or I will answer my own question, for the benefit of others with the same ignorance :-)
Querying for element type data
I am rather new to Umbraco and very excited about this well-built cms. Wow.
I am looking for advice on how to query for the element data types. I found many examples for querying content node data, but it does not work for element types.
Example: I defined an element data type "car" which can be used in nested control property editors on several pages.
I have 2 different questions:
MyCars
with a nested content controlcars
which can have items of data typecar
, how do I query for allcar
items on that page?car
items in any nested content control on any page underneath a specific page (all descendant content nodes), which the least performance hit?I would be very grateful for a hint into the right direction.
Best regards! Mikael
Hello Mikael
Welcome to our the friendliest community!
Rendering a nested content is easy, you need to use something like this:
docs - https://our.umbraco.com/documentation/getting-started/backoffice/property-editors/built-in-property-editors/Nested-Content/#rendering-nested-content
Thanks, Alex
Hello Alex,
first let me say that it is amazing how much I can feel and perceive the remarkable friendliness of the Umbraco community, both here in the forum and also elsewhere when I read from and interact with people contributing to Umbraco. In a way, this makes me want to contribute as well, both as a programmer and as a human being, so to speak.
Thank you for your input. Somehow I missed this part of the docs.
As far as my second question goes, I am still unclear. I am experimenting and will come back with another followup question (or I will answer my own question, for the benefit of others with the same ignorance :-)
Best regards! Mikael
is working on a reply...