How to show extra fields for K2 related items

  • Comments:View comments
Rate this item
(4 votes)

You need to display K2 extra fields in the related items section in the item view, but this is not supported by K2, here is how to do it...

 

This can be done by hacking the components/com_k2/models/itemlist.php file, at line: 955
add this line:

$rows[$key]->extra_fields = $model->getItemExtraFields($rows[$key]->extra_fields, $rows[$key]);


after this line:

$rows[$key] = $model->execPlugins($rows[$key], 'relatedByTag', '');

This way, you can use

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

in the item.php template file to show extra fields for related items.

Read 10011 times