# Pluck structured data?

**URL:** <https://forum.getkirby.com/t/pluck-structured-data/4482>\
**Category:** Questions\
**Tags:** v2\
**Created:** [June 21, 2016, 12:01pm UTC](https://forum.getkirby.com/t/pluck-structured-data/4482 "2016-06-21T12:01:07Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

**Author:** ![judbd](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/judbd/32/1303_2.png) [@judbd](https://forum.getkirby.com/u/judbd)\
**Post date:** [June 23, 2016, 8:16pm UTC](https://forum.getkirby.com/t/pluck-structured-data/4482/16 "2016-06-23T20:16:37Z")

</div>

some follow up, a friend of mine helps me for achieving this, and I post the code here if it can help somebody else.

My first code, works but no random:

```
<?php
                $projects = page('projets')->children()->visible();
                $testimonials = new Structure();
                $key = 0;
                foreach($projects as $p) {
                  foreach($p->clientTestimonials()->toStructure() as $item) {
                    $testimonials->append($key, $item);
                    $key++;
                }
            }
            foreach ($testimonials->limit(5) as $testimonial): ?>									
            <li class="item">
               <div class="testimonial-block">
                <blockquote>
                    <?php echo $testimonial->clientTestimonial()->kt() ?>
                </blockquote>
                <div class="testimonial-avatar"><img src="http://placehold.it/100x100&amp;text=IMAGE+PLACEHOLDER" alt="" height="60" width="60"></div>
                <div class="testimonial-info">
                    <div class="testimonial-info-in">
                        <strong><?php echo $testimonial->clientTestimonialName() ?></strong><span><?php echo $testimonial->clientTestimonialRole() ?></span>
                    </div>
                </div>
            </div>
        </li>
    <?php endforeach ?> 

```

the code with “all array” in vanilla PHP + randomisation and limit to 5 items:

```
<?php
$projects = page('projets')->children()->visible();
$testimonials = array();
foreach($projects as $p) {
  foreach($p->clientTestimonials()->yaml() as $item) {
    $testimonials[] = $item;
  }
}
shuffle($testimonials);
$testimonialscount = count($testimonials);
$i = 0;
while($i < 5) { ?>
	<li class="item">
               <div class="testimonial-block">
                <blockquote>
                    <?php echo $testimonials[$i]["clientTestimonial"]; ?>
                </blockquote>
                <div class="testimonial-avatar"><img src="http://placehold.it/100x100&amp;text=IMAGE+PLACEHOLDER" alt="" height="60" width="60"></div>
                <div class="testimonial-info">
                    <div class="testimonial-info-in">
                        <strong><?php echo $testimonials[$i]["clientTestimonialName"]; ?></strong><span><?php echo $testimonials[$i]["clientTestimonialRole"]; ?></span>
                    </div>
                </div>
            </div>
        </li>
<?php	$i++;
if($i >= $testimonialscount): break; endif;
}
?>

```

Thanks everybody!

---

_[View the full topic](https://forum.getkirby.com/t/pluck-structured-data/4482)._
