PHP Joomla! 6 Joomla! 5 Joomla! 3 (Legacy) Component Intermediate

Load Filtered Articles from a Category Using ArticlesModel

Instantiates the core com_content ArticlesModel via MVCFactory with category, published state, access and limit filters.

Updated on 24 November 2026 39 copies 149 views
modules/mod_example/src/Helper/ArticlesHelper.php
<?php

declare(strict_types=1);

use Joomla\CMS\Factory;

$app     = Factory::getApplication();
$factory = $app->bootComponent('com_content')->getMVCFactory();
$model   = $factory->createModel('Articles', 'Site', ['ignore_request' => true]);

$model->setState('params', $app->getParams());
$model->setState('filter.published', 1);
$model->setState('filter.category_id', [8]);
$model->setState('filter.language', $app->getLanguageFilter());
$model->setState('list.ordering', 'a.publish_up');
$model->setState('list.direction', 'DESC');
$model->setState('list.limit', 6);

$articles = $model->getItems();
Pass ignore_request => true so URL query parameters never override your custom model state.
modules/mod_example/src/Helper/ArticlesHelper.php
<?php
JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_content/models', 'ContentModel');
$model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
$model->setState('filter.published', 1);
$model->setState('filter.category_id', 8);
$model->setState('list.limit', 6);

$articles = $model->getItems();
Legacy Joomla 3 implementation via JModelLegacy::getInstance().

Technical explanation and best practices

Avoid hand-writing SQL against #__content when fetching article lists in custom modules or components. The core ArticlesModel automatically enforces ACL levels, publish dates and active language filters.

Direct Engineering

Have a Joomla project or technical challenge in mind?

From architectural diagnosis to production deployment, directly with the engineer.