CW Field Display

CW Field Display

CW Field Display is a simple module for displaying a Joomla custom field or fields from a specific context and item.

With CW Field Display, you can either set a specific context and item ID in the module parameters, or allow it to use the current page's context and item ID. You can also set specific fields or field groups to be displayed or allow it to display all custom fields. This module gives you greater control over how and where you display custom fields on each page because it makes it possible to display custom fields outside of the component's output.

More details Sign up today!

  • Standard Joomla MVC structure
  • Display 1 or more Joomla core custom fields
  • Select fields or field groups to display or display all
  • Select context or use current page's context
  • Select item or use current page's item
  • All managed in the module editor
  • GPL License
Demo Field: This is a demo field added to articles in the "Extensions" category on this website. The text you are reading now is the value added to "Demo Field" for the "CW Field Display" article. There are 2 other custom fields for this category, but the module is set to only display the "Demo Field" custom field.

Add a CW Field Display module to any page(s) on your site

  1. In the Joomla administrator, go to Extensions > Modules and click "New" to add a new module.
  2. Select the CW Field Display module type.

Parameters Explained

  • Context: Enter the context for the field(s) to display. Leave blank to use the current page's context. Joomla core supports the following contexts relavent to this module: com_content.article, com_content.categories, com_users.user, com_contact.contact, and com_contact.categories
  • Item ID: Enter the item ID of the item associated with the field(s) to display. Leave blank to use the current page's ID or the current user's ID if the com_users.user context is to be used.
  • Field(s): Enter the name(s) of the field(s) you want to display. If you enter multiple names, separate them by a comma. Leave blank to display all fields or all fields from the group(s) entered in the Field Group(s) parameter.
  • Field Group(s): Enter the ID(s) of the field group(s) you want to display. Leave blank to include all field groups.

Creating a Template Override

If you want to override the standard layout, you have to create a template override as follows:

  1. Copy /modules/mod_cw_fielddisplay/tmpl/default.php to /templates/{YOUR_TEMPLATE}/html/mod_cw_fielddisplay/default.php *
  2. Modify as needed

The default output calls the standard layout to render all fields from com_fields. You can override this to render each field individually by looping through the $fields array variable that is passed to the layout. Each field in the array is a standard object, and has a "value" parameter and a "rawvalue" parameter. The "value" parameter is rendered through the field type's output layout, and the "rawvalue" parameter is the raw value entered for the field by the admin.

You may also use FieldsHelper::render to render a single field using the following:

echo FieldsHelper::render(
    $context,
    'field.render',
    array(
        'field' => $field
    )
);

This is assuming that $field is the variable you get when looping through the $fields array.

* Note: If you want to have multiple template overrides, you can create multiple copies of default.php, but give it different names. Each new override will be available in as an option in the Alternate Layout parameter in the Advanced parameter tab in the module.


Need help? Check out our documentation.
Pre sales questions? Email sales@corywebbmedia.com