I currently have a problem with an ajax call in my new module. the filters are not used. Here is an extract of the relevant lines:

$articleid    = $data_decoded->articleid;

// Get an instance of the generic articles model
require_once(JPATH_ADMINISTRATOR . '/components/com_content/models/articles.php');
$model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));

$model->setState('filter.article_id', $articleid);

return $model->getItems();

$articleid contains the searched article ID as an integer.

The function returns the complete list of existing articles.

The goal is to receive the searched article and / but filter also to check for access restrictions & published state...

Added: If i am using the Article Model like used below, i can also not filter is that correct? (it returns an empty article object)

require_once(JPATH_ADMINISTRATOR . '/components/com_content/models/article.php');
$model = JModelLegacy::getInstance('Article', 'ContentModel', array('ignore_request' => true));

    $model->setState('filter.article_id', 22);

    return $model->getItem();

I'm sure it's just a stupid mistake or i misunderstood something, but I just don't see...

Thanks for your feedback

  • Are you using administrator models intentionally?
    – Sharky
    Commented Jan 8, 2020 at 12:21
  • i am not sure what i can or should use, in the end it should display the articles in the frontend
    – Marco
    Commented Jan 9, 2020 at 14:31

1 Answer 1


Administrator side's ContentModelArticles does not support filtering by ID.

ContentModelArticle does support it. The state property name is article.id:

$model->setState('article.id', $articleId);

If this is a frontend module you might want to use the frontend articles model:

// Register frontend model classes.
JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_content/models', 'ContentModel');

// Get the articles model.
$model = JModelLegacy::getInstance('Articles', 'ContentModel', ['ignore_request' => true]);

// Set up dummy params to prevent errors.
$model->setState('params', new JRegistry);

// Filter by article IDs.
$model->setState('filter.article_id', $articleIds);

// Get the articles.
$articles = $model->getItems();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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