I have updated the guestbook plugin to a recent plugin skeleton using flex-objects, see GitHub - pikim/grav-plugin-guestbook: Grav Guestbook Plugin. Now I’d like to be able to paginate the stored messages in twig using the standard pagination plugin. Is this possible?
If I do
{% set collection = grav.get('flex').collection('guestbook') %}
{% do paginate(collection, 3) %}
I get the error that the types of argument 1 don’t match:
Argument 1 passed to Grav\Plugin\Pagination\PaginationHelper::__construct() must be an instance of Grav\Common\Page\Collection, instance of Grav\Common\Flex\Types\Generic\GenericIndex given
The manual says that flex collections can be paginated with the slice filter. But this way I would have to write all the business logic behind that, wouldn’t I?
@pamtbaau
Thanks. I’ll take a look at the pagination plugin.
Do you know how I can add flex layout files to plugins? I tried to copy them to user/plugins/guestbook/templates/flex/guestbook/collection/default.html.twig and user/plugins/guestbook/templates/flex/guestbook/object/default.html.twig, but that doesn’t work. I get a ERROR: Layout 'default' for flex collection 'guestbook' was not found. error on the displayed page with URL /directory:guestbook. When I copy them to the according flex-objects plugin directory, it works.
I have no idea. I’m not a flex user and I simply read/write form entries from/into a yaml file. Old school perhaps, but so far I haven’t found a compelling use-case to invest time in it. It feels too complex to my liking.