# Repeating sections

**URL:** <https://forum.getkirby.com/t/repeating-sections/20510>\
**Category:** Questions\
**Tags:** v3\
**Created:** [December 23, 2020, 7:31pm UTC](https://forum.getkirby.com/t/repeating-sections/20510 "2020-12-23T19:31:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elaltito](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/elaltito/32/7940_2.png) [@elaltito](https://forum.getkirby.com/u/elaltito)\
**Post date:** [December 23, 2020, 7:31pm UTC](https://forum.getkirby.com/t/repeating-sections/20510/1 "2020-12-23T19:31:39Z")

</div>

Hello,  
I am trying to have build a page template that will accept different types and quantities of sections snippets.

Basically I want to be able to use the same section snippet multiple times in single template, along with other snippets.

In the case of my screenshot below, I would have multiple projects (`Project-name-one, Project-name-two`, etc) each using the same template (`project.php`), and inside each project I would like to be able to reuse the same section snippet more than once, in this case: (`section-type-one`) twice, and then (`section-type-two`) once. But ultimately the projects will each be a made of a mixture of many different section snippets…

 ![Screenshot 2020-12-23 at 20.15.03](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/9/9990060a13f25ac88a83c056cc3e09fb3c4787bb.png)

I have tried using the following code inside my `project.php` template file :

```
  <?php

  foreach($page->children() as $section) {
snippet($section->uid(), ['data' => $section]);
  }

  ?>

```

I got the code almost as is from the [walkthrough about building one pagers](https://getkirby.com/docs/cookbook/templating/one-pager). But it only allows me to use each section type once. If I reuse the same section again, it only uses the last one and ignores the others.

Anyone got any ideas ? 😕

Thanks! 🙂

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [December 23, 2020, 7:38pm UTC](https://forum.getkirby.com/t/repeating-sections/20510/2 "2020-12-23T19:38:09Z")

</div>

The problem is that your sections have the same slug (`1_section-type-one` is the same as `2_section-type-one`, because the number doesn’t count for Kirby). They must have different folder names, but you can use the [intendedTemplate()](https://getkirby.com/docs/reference/objects/page/intended-template) to fetch the corresponding snippets, ie. those subpages can use different blueprints/templates.

```auto
1_section-1
  section-one.txt # or whatever you want to name your blueprints/snippets for these sections
2_section-2
  section-one.txt
3_section-3
  section-two.txt

```

Then in your template

```auto
foreach($page->children() as $section) {
  snippet($section->intendedTemplate()->name(), ['data' => $section]);
}

```

would then call `section-one.php` snippet for sections 1 + 2, and `section-two.php` snippet for section 3.

Because of the above, using the `uid` as snippet name as in the onepage documentation only makes sense for section snippets that are only used once.

---

<div class="post-metadata">

**Author:** ![elaltito](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/elaltito/32/7940_2.png) [@elaltito](https://forum.getkirby.com/u/elaltito)\
**Post date:** [December 23, 2020, 7:57pm UTC](https://forum.getkirby.com/t/repeating-sections/20510/4 "2020-12-23T19:57:10Z")

</div>

oh ok, that makes sense! Your solution worked perfectly! As usual, thank you again for your help and your unbelievably quick response time!! The 5 star kirby service 😉
