Hello everybody!
One hour of googleing wasn’t sufficient. So I’ll ask my question here. Maybe somebody dealed with the same problem before.
I have different models in my project, let’s say:
User, Product, ForumPost
At the top of my page there’s a single search input field. You shall be able to use it finding anything: users, products or forum posts. Submitting the form leads to an action method of the SearchController. In this method I create CActiveDataProvider for all three models with the appropriate criterias:
$users = new CActiveDataProvider('User', ... )
$products = new CActiveDataProvider('Product', ... )
$forumposts = new CActiveDataProvider('ForumPost', ... )
I have now three instances of CActiveDataProvider. Handing all of them over towards the view file ‘index.php’ doesn’t make sense cause I have a single CListView waiting to display all search results mingled together and just ordered by e.g. creation date or relevance:
<h1>Meine Searchengefinden</h1>
<div class="list">
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=> '_result_item.php',
); ?>
</div>
</div>
So what I want and probably need is to merge those three CActiveDataProvider into a single one because CListView just wants to have a single CActiveDataProvider.
Maybe it’s plain simple and I’m just confused by facing my code for too long. Displaying the resulting items of a search over two or more different models can’t be that complicated, eh?
Thanks in advance!