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
How to check how many items is in testimonials Archetype value?
I have
var testimonials = settingsNode.GetPropertyValue<Archetype.Models.ArchetypeModel>("testimonialsWidget");
then
var counter = 1; foreach (var item in testimonials) { //var last = counter == testimonials.Count ? " class=\"last\"" : ""; <div class="item"> <p>"@item.GetValue("text")"</p> </div> counter++; }
'testimonials' have no Count or Length value.
Thanks
Hi Eva,
Something like this:
var testimonials = Model.Content.GetPropertyValue<ArchetypeModel>("testimonialsWidget"); <p>Number of items in testimonials: @testimonials.Count()</p> foreach (var item in testimonials) { var lastClass = item.Equals(testimonials.Last()) ? "last" : null; <div class="@lastClass"> <p>@item.GetValue("text")</p> </div> }
Jeavon
Thanks Jeavon. Your example works, my example does not work because it is on other than current node.
See my comment here: http://our.umbraco.org/projects/backoffice-extensions/archetype/sound-off!/55062-check-Archetype-items-Count-or-Length
I;m still looking for a solution.
Had the same sort of issue here. I needed to count the number of items in Archetype before I began looping/using them.
I found this did not work -
var thing = Model.Content.GetPropertyValue<ArchetypeModel>("things"); @thing.count()
But I did find that this worked...
ArchetypeModel thing = Model.Content.GetPropertyValue<ArchetypeModel>("things"); @thing.Count()
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
check Archetype items' Count or Length
How to check how many items is in testimonials Archetype value?
I have
then
'testimonials' have no Count or Length value.
Thanks
Hi Eva,
Something like this:
Jeavon
Thanks Jeavon. Your example works, my example does not work because it is on other than current node.
See my comment here: http://our.umbraco.org/projects/backoffice-extensions/archetype/sound-off!/55062-check-Archetype-items-Count-or-Length
I;m still looking for a solution.
Had the same sort of issue here. I needed to count the number of items in Archetype before I began looping/using them.
I found this did not work -
But I did find that this worked...
is working on a reply...