I had a requirement to display my custom fields in a Category List display and in this article I explain how I did it but the technique can be used for more that just Custom Fields once you learn how.

Using an Alternate Layout rather than a layout override meant that I only changed the Category List layout for the display of the one category of items I wanted to display my custom fields and thus still allow me to use the normal Category List layout for the other pages and the standard custom field rendering.

You can start by looking here for some details on setting up an alternative Layout, https://docs.joomla.org/Layout_Overrides_in_Joomla . There was something missing in that documentation but with a few other articles I was able to piece together what was needed but hopefully what follows is enough to get you going.

The basic steps are;

  1. Create an override for the Category List layout in your template folder for ..\com_content\category\default*.* files.

  2. Rename the default*.* files to fred*.* in the template folder to create an alternately named copy.

  3. Edit fred_articles.php and change the column headers to match your custom headings. Owner and Expiry are my custom fields in this example.

        <th scope="col" id="categorylist_header_owner">
        <?php echo JHtml::_('grid.sort', 'Owner', 'owner', $listDirn, $listOrder); ?>
        <th scope="col" id="categorylist_expiry_date">
        <?php echo JHtml::_('grid.sort', 'Expiry', 'expiry', $listDirn, $listOrder); ?>
  4. Scroll down a bit further and change the data sections of your template to use something like

      <td headers="categorylist_header_owner" class="list-owner">
          <?php echo $article->jcfields['8']->value; ?>
          </span>             </td>           <td headers="categorylist_expiry_date" class="list-expiry">
          <?php echo $article->jcfields['7']->value; ?>

jcfields['n'] is the id of the custom field.

  1. Save fred_articles.php

  2. Edit fred.xml and change the to be the the name of your alt layout, something like; title="Fred List" option="COM_CONTENT_CATEGORY_VIEW_FREDLIST_OPTION"

  3. Depending on the template you are using you might have to edit some of the other fred*.* files so just have a scroll through the files to check..

  4. Create a language override for COM_CONTENT_CATEGORY_VIEW_MYEVENTS_OPTION in the back end to replace the text in Step 6.

  5. Create/Edit your Menu Item and select type Articles where you should see an option for 'Fred Lists'. In the next field select the Category containing your custom fields.

And that is pretty much it.