How to display a K2 extra field in Minitek modules?

You can use the following method to display a specific K2 extra field in any of our K2 modules:

  1. Create a module override in your template. Note that you must copy all the files from the module /tmpl folder to the template override folder.

    For example, for the module Responsive Scroller for K2, you must copy the files:

    • /tmpl/default.php
    • /tmpl/default_caption.php
    • /tmpl/default_light.php
    • /tmpl/default_minimal.php
    • /tmpl/default_modern.php
    • /tmpl/default_retro_dark.php
    • /tmpl/default_retro_light.php

    to:

    • /templates/YOUR_TEMPLATE/html/mod_responsive_scroller_for_k2/

    You can learn more about Joomla! template overrides at https://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core.

  2. Inside the template theme file (depends on the selected theme in the module parameters), after the line:

    defined('_JEXEC') or die('Restricted access');

    add this line:

    $k2obj = new K2ModelItem();
  3. After the line:

    <?php foreach($items as $key=>$item) { ?>

    add this line:

    <?php $fields = $k2obj->getItemExtraFields($item->extra_fields, $item); ?>
  4. Now you can add the following line anywhere in the file to display the value of a specific K2 extra field:

    <?php echo $item->extraFields->FIELD_ALIAS->value; ?>

    where FIELD_ALIAS is the extra field alias.

This website uses cookies so that we can provide you with the best user experience. By clicking "continue" you agree to cookies being used in accordance with our Cookies Policy.

Search