<p>I doubt this is possible in Twig by default because you have two different Element types, thus you'll need to different instances of the ElementQuery to populate all models correctly. I think you'll need to create your own pagination. That being said <code>Element::find()-&gt;all()</code> will throw an error </p>

<blockquote>
  <p>Cannot instantiate abstract class craft\base\Element</p>
</blockquote>

<p>Thus you'll have to Query for your elements in your own</p>

<pre><code>// get all possible element ids
$sectionId = X;
$query = (new Query())
    -&gt;select('elements.id')
    -&gt;from('{{%elements}}')
    -&gt;leftJoin('{{%elements_sites}}', 'elements_sites.elementId = elements.id')
    -&gt;leftJoin('{{%entries}}', 'entries.id = elements.id')
    -&gt;where(new OrCondition([
        ['=', 'entries.sectionId', $sectionId], &lt;-- your section Id
        ['is', 'entries.sectionId', null],
    ]))
    -&gt;andWhere(new OrCondition([
        ['=', 'elements.type', \craft\elements\Entry::class],
        ['=', 'elements.type', YourCalenderClassComesHere],
    ]))
    -&gt;andWhere(['elements_sites.siteId' =&gt; 1])
    -&gt;limit(10)
    -&gt;offset(0)
    -&gt;column();

// populate entry by Id
foreach ($query as $elementId){
    $element = Craft::$app-&gt;getElements()-&gt;getElementById($elementId);
}
</code></pre>

CC BY-SA 4.0
2018-05-27T19:23:01.653Z
Wow, thanks Robin. What a complete answer. I've yet to test myself with Craft Plugin work so I'll give writing one a go with this! Assuming you'd recommend this to be implemented in plugin form?
Jay
CC BY-SA 4.0
2018-05-27T19:24:45.093Z
You need to implement it via plugin or module, these are the only ways to access custom php code. There are a few other checks you might want to include. The easiest is to run `Entry::find()->getRawSql()` to see all conditions Craft includes by default
Robin Schambach
CC BY-SA 4.0
2018-05-27T19:35:13.707Z
This is great. Thanks for your help. I'll be sure to try and write my first plugin with this then! Cheers again. 
Jay
CC BY-SA 4.0
2018-05-25T12:42:58.160Z
2018-05-25T12:42:58.160Z
Robin Schambach
<p>I have installed the Calendar plugin and I'd like to search across event entries from this plugin and from channel/section entries across the base Craft 3 site.</p>

<p>However, I am getting the usual Limit-Array error when trying to paginate the results.</p>

<p>Is there a method for paginating multiple search results in Craft 3? I haven't come across a way to do this in any current questions or Craft 3 Docs.</p>

<craft3><search>
Paginate search results after combining sections in Craft 3
# Paginate search results after combining sections in Craft 3

(Asked by: username_0 on 2018-05-25)

I have installed the Calendar plugin and I'd like to search across event entries from this plugin and from channel/section entries across the base Craft 3 site.

However, I am getting the usual Limit-Array error when trying to paginate the results.

Is there a method for paginating multiple search results in Craft 3? I haven't come across a way to do this in any current questions or Craft 3 Docs.

**Tags:** craft3, search


---

## 1 answers

### Answer by username_1 on 2018-05-25. Score: 2 | Accepted answer

I doubt this is possible in Twig by default because you have two different Element types, thus you'll need to different instances of the ElementQuery to populate all models correctly. I think you'll need to create your own pagination. That being said Element::find()->all() will throw an error 

Cannot instantiate abstract class craft\base\Element

Thus you'll have to Query for your elements in your own
// get all possible element ids
$sectionId = X;
$query = (new Query())
    ->select('elements.id')
    ->from('{{%elements}}')
    ->leftJoin('{{%elements_sites}}', 'elements_sites.elementId = elements.id')
    ->leftJoin('{{%entries}}', 'entries.id = elements.id')
    ->where(new OrCondition([
        ['=', 'entries.sectionId', $sectionId], <-- your section Id
        ['is', 'entries.sectionId', null],
    ]))
    ->andWhere(new OrCondition([
        ['=', 'elements.type', \craft\elements\Entry::class],
        ['=', 'elements.type', YourCalenderClassComesHere],
    ]))
    ->andWhere(['elements_sites.siteId' => 1])
    ->limit(10)
    ->offset(0)
    ->column();

// populate entry by Id
foreach ($query as $elementId){
    $element = Craft::$app->getElements()->getElementById($elementId);
}

> **Comments:**
> **username_0**: Wow, thanks Robin. What a complete answer. I've yet to test myself with Craft Plugin work so I'll give writing one a go with this! Assuming you'd recommend this to be implemented in plugin form?  
> **username_1**: You need to implement it via plugin or module, these are the only ways to access custom php code. There are a few other checks you might want to include. The easiest is to run `Entry::find()->getRawSql()` to see all conditions Craft includes by default  
> **username_0**: This is great. Thanks for your help. I'll be sure to try and write my first plugin with this then! Cheers again.   

---

