# Fetching Structure field value by category

**URL:** <https://forum.getkirby.com/t/fetching-structure-field-value-by-category/8473>\
**Category:** Questions\
**Tags:** v2\
**Created:** [September 11, 2017, 8:13am UTC](https://forum.getkirby.com/t/fetching-structure-field-value-by-category/8473 "2017-09-11T08:13:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryuchix](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ryuchix/32/4732_2.png) [@ryuchix](https://forum.getkirby.com/u/ryuchix)\
**Post date:** [September 11, 2017, 8:13am UTC](https://forum.getkirby.com/t/fetching-structure-field-value-by-category/8473/1 "2017-09-11T08:13:42Z")

</div>

I am getting values from a structure fields. i wanna ask if how to fetch them by category (i used select)

heres my yml

```auto
fields: 
  menu_name: 
   label: Menu name
   type: text
   required: true
    help: >
      Place name of partner here.
  menu_link:
    label: Menu url
    type: text
    help: >
      Place link url of Partner's website.
  category:
    label: Parent Menu
    type: select
    options:
      online_services: Online services
      other_sites: Other sites
      keep_up_to_date: Keep up to date
      calendar: Calendar

```

PHP

```
  <?php
  $menuss = $site->menuitems()->toStructure(); ?>    
<?php foreach($menuss as $xxxx): ?>
                    <li role="menuitem"><a href="<?php echo $xxxx->menu_link() ?>"><?php echo $xxxx->menu_name() ?></a></li>
                <?php endforeach ?>

```

---

<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:** [September 11, 2017, 8:21am UTC](https://forum.getkirby.com/t/fetching-structure-field-value-by-category/8473/2 "2017-09-11T08:21:23Z")

</div>

What exactly do you mean? Do you want to filter items by category? Then you can use `filterBy`:

```auto
$onlineServices = $page->menuitems->structure()->filterBy('category', 'online_services');

```

---

<div class="post-metadata">

**Author:** ![ryuchix](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ryuchix/32/4732_2.png) [@ryuchix](https://forum.getkirby.com/u/ryuchix)\
**Post date:** [September 11, 2017, 8:24am UTC](https://forum.getkirby.com/t/fetching-structure-field-value-by-category/8473/3 "2017-09-11T08:24:10Z")

</div>

damn… sorry i didnt look for the filter keyword… you saved me.

thanks texnixe

---

<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:32pm UTC](https://forum.getkirby.com/t/fetching-structure-field-value-by-category/8473/4 "2025-02-06T17:32:09Z")

</div>


