Blocks with AJAX - Controller?

Hi Kirby friends,

I would like to build a dynamic block with ajax “load more” button from other pages.

My CarOverview Block works great with this code and I see all five cars:

$cars = $pages
    ->find('collection')
    ->children()
    ->listed()
    ->filterBy('category', $block->content()->category())
    ->paginate(5);

    //... foreach loop with cars ....

Could you give me some advices, should I create a controller or model? My idea is to use this block on different pages and load more cars over ajax.

Cheers
Leff

Probably best with a block model.

Thank you! Can I write it directly to site/models/carOverview.php or should I use the plugin? Do you have a good example for a block model?

No, that folder is only useful for page models.

You load a block model in a plugin. No, I don’t have an example.