# Kirby-index-field for structure data

**URL:** <https://forum.getkirby.com/t/kirby-index-field-for-structure-data/10613>\
**Category:** Questions\
**Tags:** v2\
**Created:** [June 12, 2018, 6:21pm UTC](https://forum.getkirby.com/t/kirby-index-field-for-structure-data/10613 "2018-06-12T18:21:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clause](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@Clause](https://forum.getkirby.com/u/Clause)\
**Post date:** [June 12, 2018, 6:21pm UTC](https://forum.getkirby.com/t/kirby-index-field-for-structure-data/10613/1 "2018-06-12T18:21:53Z")

</div>

I have the »kirby-index-field« [[https://github.com/jongacnik/kirby-index-field](https://github.com/jongacnik/kirby-index-field)] on the site, this works fine to show fast the children pages.

I want to add the »kirby-index-field« to one page where i have structure data.

Now i added in the `options.php` on the `function items` this case:

```
 case 'structure':
         $items = $page->Mitarbeiter()->toStructure();
         break;

```

But this will not work…

How i can get the data of the structure field?

The structure in the TXT-File is like this:

```
Mitarbeiter: 

- 
  mitarbeiter: intern/personen/vorname-nachname
  eintritt: 2000-09-01
  austritt: 2003-05-01
  ma_ansprech: "0"
- 
  mitarbeiter: intern/personen/vorname-nachname
  eintritt: 2003-05-01
  austritt: ""
  ma_ansprech: "1"

```

The Blueprint is this:

```
  mitarbeiter:
    label: Mitarbeiter
    type: index
    options: structure
    filter: MyDataFilters::gruppen
    rows: 10
    columns:
      mitarbeiter: Mitarbeiter
      eintritt: Eintritt
      austritt: Austritt
      ma_ansprech: Ansprechperson

```

---

<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:** [June 12, 2018, 6:40pm UTC](https://forum.getkirby.com/t/kirby-index-field-for-structure-data/10613/2 "2018-06-12T18:40:55Z")

</div>

That doesn’t make sense. What sort of options would you expect to see? After all, a structure entry consists of of multiple subentries…

Are these “Mitarbeiters” pages?

Then you could try this:

```auto
case 'structure':
        $options = [];
        $items = $page->mitarbeiter()->toStructure();
        foreach($items as $item) {
          $options[] = $item->mitarbeiter()->toPage();
        }
        $items = new Collection($options);
        break;

```

---

<div class="post-metadata">

**Author:** ![Clause](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@Clause](https://forum.getkirby.com/u/Clause)\
**Post date:** [June 12, 2018, 6:56pm UTC](https://forum.getkirby.com/t/kirby-index-field-for-structure-data/10613/3 "2018-06-12T18:56:44Z")

</div>

I want to show the structure-content via the »kirby-index-field« because there i can use the data filter.  
My Problem is that the Plugin works not for the include structure in the page.  
That’s why I want to extend the plugin to the structure.

The page is for a society and this is on a group-page where i can add people to the group.

I would test your Solution…

---

<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:** [June 12, 2018, 7:09pm UTC](https://forum.getkirby.com/t/kirby-index-field-for-structure-data/10613/4 "2018-06-12T19:09:37Z")

</div>

I see so you want to show all information from the entries in a table. The above will work in a select field, but I don’t know if it makes sense for the index field.

Edit: It should actually work like this:

```auto
        case 'structure':
                $items = $page->links()->yaml();
                $items = new Collection($items);
                break;

```

---

<div class="post-metadata">

**Author:** ![Clause](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@Clause](https://forum.getkirby.com/u/Clause)\
**Post date:** [June 12, 2018, 7:47pm UTC](https://forum.getkirby.com/t/kirby-index-field-for-structure-data/10613/5 "2018-06-12T19:47:38Z")

</div>

BINGO! Thats it!  
Thank You Sonja!

I have been testing the YAML as well, but forget the Collection!

---

<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:** [June 12, 2018, 8:55pm UTC](https://forum.getkirby.com/t/kirby-index-field-for-structure-data/10613/6 "2018-06-12T20:55:54Z")

</div>

While this works, it is nevertheless a pretty stupid hack because it doesn’t belong in the page options and also because you have to hardcode a field name. It would make more sense to have an additional options method “optionsFromStructure” or something like that.

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:27pm UTC](https://forum.getkirby.com/t/kirby-index-field-for-structure-data/10613/7 "2025-02-06T17:27:59Z")

</div>

Archived on February 6, 2025, 5:27pm UTC


