Showing Properties from Item using the query builder
I am using the "ModelsBuilder" Mode and I am testing the Query Builder to get a list of all my "News" items but it seems like it is only able to get the Name and Url for the items but nothing else..
Thank you for the very clear explanation and the cheat sheet, I will try to get more familiar with it so I can keep learning and improving with Umbraco!
Showing Properties from Item using the query builder
I am using the "ModelsBuilder" Mode and I am testing the Query Builder to get a list of all my "News" items but it seems like it is only able to get the Name and Url for the items but nothing else..
This is the code that got generated.
I would like to be able to get the properties like Title and Short Description
Also, I was trying to update the query so it would only generated a list of items between Start Date and End
Hi Yaco
'ChildrenOfType' returns an IEnumerable of IPublishedContent - where each IPublishedContent item represents your news item in a 'generic way'.
With IPublishedContent you can access the properties using the .Value helper
So in your example above you'd be able to write out your title and Short Description by using their alias in the backoffice on the doc type.
so
But if you want to use the 'Modelsbuilder' approach to listing out the children then you would have instead
Here Umbraco knows the children are explicitly NewsItemPage types and so you can use the strongly typed property access instead of .Value
You can then use the properties for filtering too eg
This cheatsheet is geared for using Modelsbuilder and might give you some hints for working with Children etc
https://drive.google.com/file/d/171sMUOjjKv-bvlFEDNk7WN0I_UD9g670/view
regards
Marc
Thank you for the very clear explanation and the cheat sheet, I will try to get more familiar with it so I can keep learning and improving with Umbraco!
is working on a reply...