No Code Attached Yet
avatar Scrabble96
Scrabble96
20 Oct 2025

What needs to be fixed

mod_articles module

Why this should be fixed

If you want to include custom fields that do not display automatically in an article, they won't display.

Further info: I have a category for an annual concert series that is composed entirely of fields, e.g. date, time, location, concert info, ticket price, Youtube links, etc., none of which display automatically in the article editing area. Each field has its own CSS style and some have related JS. This means that the information is displayed in a consistent way across each article and (non-admin, on the front) editors can be sure to put the right information in the right place. The concerts are shown in a blog and also in modules created from mod_articlescategory overrides showing selected fields.

I discovered yesterday that something has happened so that a module from a previous concert season displayed on a newly created menu item only shows the article title - but three fields on the original page - which made me think that something has changed in the mod_articlescategory module, so I started to create a new module override from the mod_articles module.

Simply adding the html for the fields didn't work. See example of code:

<div class="concert-date"><?php $customFields = FieldsHelper::getFields('com_content.article', $item, true);
$values = array_column($customFields, 'value', 'name');
      echo $values['concert-long-date-and-time']; ?></div>

But, having added the line of FieldsHelper code as below the new module now displays the fields as expected.

How would you fix it

Simply add
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
to line 16 in /templates/[template-name]/html/mod_articles/default_items.php

Side Effects expected

None

avatar Scrabble96 Scrabble96 - open - 20 Oct 2025
avatar joomla-cms-bot joomla-cms-bot - change - 20 Oct 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 20 Oct 2025
avatar richard67
richard67 - comment - 20 Oct 2025

@Scrabble96 The core file does not use the FieldsHelper, so adding an include (use) statement to the code file would result in an unused use statement, which violates our code style.

If you want to use it in an override, you can use the full qualified class name. In your example code this would be:

<div class="concert-date"><?php $customFields = Joomla\Component\Fields\Administrator\Helper\FieldsHelper::getFields('com_content.article', $item, true);
$values = array_column($customFields, 'value', 'name');
      echo $values['concert-long-date-and-time']; ?></div>

Does that help?

avatar brianteeman
brianteeman - comment - 20 Oct 2025

@richard67 I undeerstand what you are saying but you should really be able to display an articles custom fields when the article is displayed in a module. Maybe this code proposal is not perfect/correct but the missing functionality is a real world problem that needs to be resolved

avatar richard67
richard67 - comment - 20 Oct 2025

Does that mean that in the old legacy mod_articles_category it was working, and in the new mod_articles not?

avatar Scrabble96
Scrabble96 - comment - 20 Oct 2025

Does that mean that in the old legacy mod_articles_category it was working, and in the new mod_articles not?

Yes. But only partially. All the ones I am concerned about are module overrides that I created a few years ago. Modules that I created last season display correctly but in one case I made a copy of a module and changed the category and then only the titles appeared. The category was simply a change from 2024-25 to 2025-26 within the same 'Season' parent category. All fields etc are the same.

Also, when I created a new module using my existing legacy mod_articles_category override, it had the same issue - the fields didn't display. I had changed nothing in the code prior to today.

Which is why I thought I'd better try out the new mod_articles module instead.

avatar Scrabble96
Scrabble96 - comment - 20 Oct 2025

If you want to use it in an override, you can use the full qualified class name. In your example code this would be:

<div class="concert-date"><?php $customFields = Joomla\Component\Fields\Administrator\Helper\FieldsHelper::getFields('com_content.article', $item, true);
$values = array_column($customFields, 'value', 'name');
      echo $values['concert-long-date-and-time']; ?></div>

Does that help?

I changed my override so all fields were requested as above. It worked... until I removed the

use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;

and then I just got a blank white screen, losing everything on the page.

avatar Scrabble96
Scrabble96 - comment - 20 Oct 2025

And when I used mod_articles_news I used to add fields like this:

<div class="concert-date"><?php echo $item->jcfields[25]->value; ?></div>

So simple, but it doesn't work in the new mod_articles

avatar joomdonation joomdonation - change - 31 Jan 2026
Status New Closed
Closed_Date 0000-00-00 00:00:00 2026-01-31 05:33:01
Closed_By joomdonation
avatar joomdonation joomdonation - close - 31 Jan 2026
avatar joomdonation
joomdonation - comment - 31 Jan 2026

I'm closing this issue:

  • The code which @Scrabble96 want to add is not needed by Joomla core. It is just being added to fix issue with the override created before
  • The code to allow easier rendering custom fields in module should be possible with this PR #45813
avatar Scrabble96
Scrabble96 - comment - 7 Mar 2026

Could someone please re-open this issue? I don't have permission to do so. Thank you.

This problem still exists. Here are steps to reproduce it:

  1. Create a custom field or use an existing field with the Options > Display Options > Automatic Display > set as 'Do not automatically display'. Assign it to a category and then add a value to that field in the latest article in that category.

  2. Go to your site template and create a new mod_articles module override (it will appear under the 'html' folder).

  3. In [modulename]_items.php - say before the 'ul' opening tag - add

<div><?php $customFields = FieldsHelper::getFields('com_content.article', $item, true);
$values = array_column($customFields, 'value', 'name');
echo $values['field-name']; ?></div>

replacing 'field-name' with your field's name.

NB. If the module's name isn't 'default' you will need to change 'default' to your module's name on lines 43 and 48 of [modulename].php

  1. Save the file and then go back to Content > Site Modules and create a new site module of the type 'Articles'. Choose the category that your article is in and ensure that it will display the latest article (i.e. the one to which you added the field data).

  2. In the module's 'Advanced' tab, select your new custom module from the 'Layout' option.
    Select a position and menu item (ideally a test page) to display it on and then save the module.
    Go to that menu item and refresh the page. I believe you will get a blank white screen.

So...

  1. Go back to [modulename]_items.php and add
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;

after

use Joomla\CMS\Language\Text;
  1. Save and refresh the website page.

Expected result

After following the above steps, I believe you should now be able to see the page with the module displayed and showing field value.

Actual result

Blank white page.

System Information

Joomla! 5.4.1 Stable
PHP 8.3.30 on Linux
Database type mysql, 10.6.24-MariaDB-cll-lve-log

Additional Comments
I can't understand why this issue was closed when it hasn't been fixed.

avatar richard67 richard67 - change - 7 Mar 2026
Status Closed New
Closed_Date 2026-01-31 05:33:01
Closed_By joomdonation
avatar richard67 richard67 - reopen - 7 Mar 2026
avatar richard67
richard67 - comment - 7 Mar 2026

I'm closing this issue:

* The code which [@Scrabble96](https://github.com/Scrabble96) want to add is not needed by Joomla core. It is just being added to fix issue with the override created before

* The code to allow easier rendering custom fields in module should be possible with this PR [[5.4] onContentPrepare event for mod_articles #45813](https://github.com/joomla/joomla-cms/pull/45813)

@joomdonation The mentioned PR in the 2nd point has been closed without merging. Am re-opening due to the OP request. Feel free to close again if this is wrong.

avatar joomdonation
joomdonation - comment - 7 Mar 2026

@Scrabble96 It is not a problem with Joomla code but your code is wrong. In step #3 you mentioned, if you put the code before the opening ul tag, the variable $item is not available, and that's the reason causing the error

If you put the code inside li tag, it will work well.

avatar Scrabble96
Scrabble96 - comment - 7 Mar 2026

@Scrabble96 It is not a problem with Joomla code but your code is wrong. In step #3 you mentioned, if you put the code before the opening ul tag, the variable $item is not available, and that's the reason causing the error

If you put the code inside li tag, it will work well.

Sorry, my mistake, BUT, putting the code in the li tag it still doesn't work without the Fields Helper. This is my code for one of my overrides _items.php files:

<?php

/**
 * @package     Joomla.Site
 * @subpackage  mod_articles
 *
 * @copyright   (C) 2024 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;

if ($params->get('articles_layout') == 1) {
    $gridCols = 'grid-cols-' . $params->get('layout_columns');
}

?>
<ul class="mod-articles-items<?php echo ($params->get('articles_layout') == 1 ? ' mod-articles-grid ' . $gridCols : ''); ?> mod-list newsreviews">
    <?php foreach ($items as $item) : ?>
        <?php
        $displayInfo = $item->displayHits || $item->displayAuthorName || $item->displayCategoryTitle || $item->displayDate;
        ?>
        <li>
            <article class="mod-articles-item" itemscope itemtype="https://schema.org/Article">

                <?php if ($params->get('item_title') || $displayInfo || $params->get('show_tags') || $params->get('show_introtext') || $params->get('show_readmore')) : ?>
                    <div class="mod-articles-item-content">
                      <div class="long-title"><a href="<?php echo $item->link; ?>" title="read more"><?php $customFields = FieldsHelper::getFields('com_content.article', $item, true);
$values = array_column($customFields, 'value', 'name');
      echo $values['review-display-title']; ?></a></div>
               <?php if ($item->displayDate) : ?>
                  <div class="mod-articles-date review-date"><em>Published date: <?php echo $item->displayDate; ?></em>
                                    </div>
                                <?php endif; ?>
                    </div>
                <?php endif; ?>
            </article>
        </li>
    <?php endforeach; ?>
</ul>

Try this code with one of your own fields with and without the FieldHelper.

avatar joomdonation
joomdonation - comment - 7 Mar 2026

I don't understand the issue. If you want to call

$customFields = FieldsHelper::getFields('com_content.article', $item, true)

Then you will need to add use Joomla\Component\Fields\Administrator\Helper\FieldsHelper; at the top of file. That's required by php. So exactly what's the problem here?

avatar richard67
richard67 - comment - 7 Mar 2026

Joomla\Component\Fields\Administrator\Helper\FieldsHelper

Or if you don't want to add the use statement at the top, you have to use the full qualified class name in your call, like this:

$customFields = Joomla\Component\Fields\Administrator\Helper\FieldsHelper::getFields('com_content.article', $item, true):
avatar Scrabble96
Scrabble96 - comment - 7 Mar 2026

I don't understand the issue. If you want to call

$customFields = FieldsHelper::getFields('com_content.article', $item, true)

Then you will need to add use Joomla\Component\Fields\Administrator\Helper\FieldsHelper; at the top of file. That's required by php. So exactly what's the problem here?

My original query was because the 'legacy' modules didn't need either of those lines of codes. All you had to put inside the li tag to display a field's value was a short line of code like this:

<div class="date"><?php echo $item->jcfields[25]->value; ?>:</div>

So easy.
But soooo confusing when the new mod_articles was introduced with no explanation as to why that code wouldn't work and what to do instead.

From what I understand from the comments above, the only way to display fields in this module is to use that much longer line of code inside the li tag and the FieldsHelper at the top of the file.

If there's a simpler way of calling field values - as previously - please let me know.

avatar joomdonation
joomdonation - comment - 7 Mar 2026

That's clear now and you really should describe the issue like you did in the last comment. The PR #45813 should allow you to use that shorter code, but for some reasons it was closed. @chmst Not sure why you closed the PR?

avatar Scrabble96
Scrabble96 - comment - 7 Mar 2026

That's clear now and you really should describe the issue like you did in the last comment. The PR #45813 should allow you to use that shorter code, but for some reasons it was closed. @chmst Not sure why you closed the PR?

Thanks. I did demonstrate that short code in one of my comments last October, but I now see I should have done so in my original post.

Add a Comment

Login with GitHub to post a comment