I group pages in a navigation by a select field (‘category_type’). <?= $group ?> displays the text, how can I display the value?
<?php
$groups = $level1->children()->listed()->groupBy('category_type');
foreach($groups as $group => $items):
?>
<ul>
<li><?= $group ?></li>
<?php foreach($items as $item): ?>
<li><a href="<?= $item->url() ?>"><?= $item->title() ?></a></li>
<?php endforeach ?>
</ul>
<?php endforeach ?>
Thanks!
Which value? $group
is already the value stored in the content file?
Oh, sorry, should have posted the select field blueprint:
category_type:
label: Art
type: select
options:
category_type_1: Standard
It display “category_type_1”, not “Standard”.
I see, so the text label from the panel. But that is only available to you via the blueprint, or you create a category map (an array of key-value pairs) in your config, which would probably be preferable as you wouldn’t have to read the complete blueprint.
Getting it from blueprint:
Ah, ok. I thought I was missing something like $group->value().
That helped, thanks Sonja!