1

i'm trying to filter articles by custom fields. In Wordpress it's quite easy to do, but i'm blocked now.

Here's what i would imagine right to do, but it's not:

JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_content/models', 'ContentModel');

// Get an instance of the generic articles model
$model = JModel::getInstance('Articles');

// Set application parameters in model
$app       = JFactory::getApplication();
$appParams = $app->getParams();

$model->setState('params', $appParams);

// Tri
$model->setState('filter.category_id', $catid);

// Isn't it possible??
$model->setState('filter.jcfields.test', "TEST");


// Retrives items
$items = $model->getItems();

dump($items);

Any ideas?

Thanks a lot.

1

May be this solution will answer to your question: JL Content Fields Filter.

  • 1
    Interesting extension thanks for sharing. Just for the sake of completeness consider to add more details in your answer about how this extension may help the OP - otherwise this answer should be converted to a comment. – FFrewin Jan 24 '18 at 12:43
  • Interresting, but does not Joomla offers a way to do it without installing a tierce plugin or module? – LiliwoL Jan 24 '18 at 15:12
1

Joomla! doesn't provide this function and it's quite a shame. There is no filter, nor ordering by default. The only way to do that correctly is to use http://easylayouts.net/ extention. It provides ordering and filtering on menu items AND a great com_content override system. There is some place for improvment, but still it solves a lot of things.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.