I'm trying to get all the articles from a specific category with a specific value in one of the custom fields (com_fields) I have created.
I have this code:
$model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true)); $model->setState('params', JFactory::getApplication()->getParams()); $model->setState('filter.category_id', 22); $articles = $model->getItems();
This brings up 2 different problems.
- It gets all the articles from a specific category. But without the com_fields values
- This gets all the articles, and in adding the com_fields values I can filter these articles but the problem is that it put unnecessary load on the webserver. Is there some sort of better solution to only get the articles with the custom field value?