Fetching Structure field value by category

php-extension
panel

#1

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

heres my yml

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 ?>

#2

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

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

#3

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

thanks texnixe