I need to show only certain menu carts on certain pages (the sections from the one-pager). Right now, I see all menu carts on all pages (the sections from the one-pager).
It would be cool, if I could use blueprint checkboxes (or another approach) in the panel to select the menu carts for each page.
That should be no problem, either use checkboxes or the multi-select custom field. I’m not quite sure how to help you? Selecting the pages to show as options?
fields:
selectMenu:
label: Select menu to show on page
type: checkboxes
options: query
query:
page: menu
fetch: children
text: '{{title}}'
value: '{{uri}}'
<?php
// create a new Pages object
$menuCollection = new Pages();
// fetch the value from the field into an array of URIs
$selectMenu = $page->selectMenu()->split(',');
// loop through the array and add each page to the new Pages object
foreach($selectMenu as $menuItem) {
$menuCollection->add($menuItem);
}
// loopy loop
foreach($menuCollection as $item): ?>
<div class="col-sm-12">
<button type="button" class="btn-card" data-toggle="modal" data-target="#modal-<?php echo str::slug($item->title()->lower()->html()) ?>"><?php echo $item->title()->html() ?>
<?php if($item->description()->isNotEmpty()): ?>
// <?php echo $item->description()->html() ?>
<?php endif ?>
</button>
</div>
<?php endforeach ?>