Reputation: 45
In category.php model, there is a bunch of $model->setState filters, that shapes the output of articles.
I am trying to add new setState, that will filter output of articles by given id's
$model->setState('filter.id', $params->get('id_articles', array());
but still wont filter. So i tried with direct id input:
$model->setState('filter.id', '280');
and still, the output is not filtered at all.
To be sure if this kind of filter works, i modified the model->setState for featured articles:
$model->setState('filter.featured', 'only');
and this proves that $model->setState works properly, but it won't accept filtering by article id.
Any ideas? Thanks!
Upvotes: 1
Views: 514
Reputation: 30
in your populateState() method set the state to :
$articleIds = explode(',', $params->get('id_articles'));
$this->setState('filter.article_id', $articleIds);
$this->setState('filter.article_id', $articleIds);
then in your getItems() method just set the state in the model to:
$model->setState('filter.article_id', $this->getState('filter.article_id'));
and you'll get the desired result.
Upvotes: 2