How can I paginate an associated model?

I have 2 models, Subsite and News, with a belongsToMany association.

I’m trying to retrieve a Subsite and its associated News items. This bit is fine, but I’d like to paginate the News items which are returned.

My find query is:

        $query = $subsites->find('all')
                                ->where(['' => $subsite])

I’m not sure whether it’s possible to paginate the News items or not; if so, where do I put the pagination array? I tried putting the following in my SubsitesTable:

    public $paginate = [
        'News' => [
            'limit' => 25,
            'order' => [
                '' => 'desc'

but I still get all news items returned. Thanks!

Leave parenthesis blank:

$query = $subsites->find()
                                ->where(['' => $subsite])

Something like that. In one of mine I use a custom pagination and looks like:

$query = $dogs->find()
                ->where(['adopted' => 0])

Thank you! That’s helpful.

Glad it helped you out.