Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I'm using Archetype property editor and trying to grab only the first fieldset using foreach:
foreach (var item in Umbraco.Content(5369).GetPropertyValue<Archetype.Models.ArchetypeModel>("myProperty")) { var icon = Umbraco.TypedMedia(item.GetValue("icon")); <img src="@icon.Url" /> <span>@item.GetValue("iconTitle")</span> }
How can I get only the first fieldset ?
Dan
Hi Dan,
Maybe you could do something like this:
foreach (var item in Umbraco.Content(5369).GetPropertyValue<Archetype.Models.ArchetypeModel>("myProperty").First()) { var icon = Umbraco.TypedMedia(item.GetValue("icon")); <img src="@icon.Url" /> <span>@item.GetValue("iconTitle")</span> }
Hope this helps,
/Dennis
I get an error 'ArchetypeModel' does not contain a definition for 'First'. Note there is one property with multiple fildesets (each fiedset has 2 fields).
Thanks
Maybe this thread can be a help to solve your needs.
http://our.umbraco.org/forum/developers/razor/54022-Checking-if-node-is-first-node-in-archetype
Thanks Dennis, but this doesn't work for me, same error as before. Fieldsets are of type {Archetype.Models.ArchetypeFieldsetModel}
I'm using an Archetype with multiple properties in each item, here's some code I just tested that works:
@{ ArchetypeModel test = Model.Content.GetPropertyValue<ArchetypeModel>("contentStack"); foreach (var Slide in Model.Content.GetPropertyValue<ArchetypeModel>("contentStack")){ if (Slide == test.First()) { <pre>First Archetype Fieldset!</pre> } else { <pre>Not the first</pre> } } }
Note I am using ArchetypeModel, not ArchetypFieldsetModel... Any reason why your using the ArchetypeFieldSetModel???
For me, I debugged my example code and according to my debug the return from Archetype is a Archetype.Models.ArchetypeModel as per the below code
var test = Model.Content.GetPropertyValue("contentStack"); <pre>@test.GetType()</pre>
I'm just working of the classic Archetype docs here : https://gist.github.com/kgiszewski/8863822
Hope it helps!!!!
Danny "Blatant"
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Get only the first fieldset from property
Hi,
I'm using Archetype property editor and trying to grab only the first fieldset using foreach:
How can I get only the first fieldset ?
Dan
Hi Dan,
Maybe you could do something like this:
Hope this helps,
/Dennis
I get an error 'ArchetypeModel' does not contain a definition for 'First'. Note there is one property with multiple fildesets (each fiedset has 2 fields).
Thanks
Hi Dan,
Maybe this thread can be a help to solve your needs.
http://our.umbraco.org/forum/developers/razor/54022-Checking-if-node-is-first-node-in-archetype
/Dennis
Thanks Dennis, but this doesn't work for me, same error as before. Fieldsets are of type {Archetype.Models.ArchetypeFieldsetModel}
Hi Dan,
I'm using an Archetype with multiple properties in each item, here's some code I just tested that works:
Note I am using ArchetypeModel, not ArchetypFieldsetModel... Any reason why your using the ArchetypeFieldSetModel???
For me, I debugged my example code and according to my debug the return from Archetype is a Archetype.Models.ArchetypeModel as per the below code
I'm just working of the classic Archetype docs here : https://gist.github.com/kgiszewski/8863822
Hope it helps!!!!
Danny "Blatant"
is working on a reply...