Hello, I have an events page where I would like the client to be able to add categories to each event, I have managed to do this with my blueprint
tabs:
content:
columns:
label: Page Content
fields:
eventCategories:
label: Categories that events can be filtered by.
type: tags
sort: asc
events:
type: structure
label: Upcoming Events
sortBy: startdate desc
fields:
title:
label: Event Title
type: textarea
category:
label: Type of Event
type: select
width: 1/2
default: All
options:
type: query
query: page.eventCategories.split
This all works, I then have a filter block that uses Alpine.js but I am getting an error
This is the filter block
<div x-data="{ tab: 'all' }">
<div class="sort">
<ul class="sort--links">
<?php foreach ($page->eventCategories()->split() as $item): ?>
<li class="link--item">
<a href="#" @click.prevent="tab = '<?= $item->title()->lower() ?>'" :class="{ 'active' : tab === 'all' }"><?= html($item->title()) ?></a>
</li>
<?php endforeach ?>
</ul>
</div>
And I get the error 'Call to a member function title() on string`, I have also tried <?= $item->value()->lower() ?>
which doesn’t work either.
I am successfully calling in the category with this code further down the same page
<?php $events = $page->events()->toStructure();
$sortedEvents = $events->filter(function ($child) {
return $child->startdate()->toDate() > time() && $child->enddate()->toDate() < time();
})->flip();
foreach ($sortedEvents as $item): ?>
<div class="event--block" x-show="tab === '<?= $item->category()->lower() ?>' || tab === 'all'">: ?>
Any help would be appreciated.