Skip to content

Instantly share code, notes, and snippets.

@Yiannistaos
Last active June 6, 2019 23:41
Show Gist options
  • Save Yiannistaos/b5734e15e613eae4d0f2fe3102faeefb to your computer and use it in GitHub Desktop.
Save Yiannistaos/b5734e15e613eae4d0f2fe3102faeefb to your computer and use it in GitHub Desktop.
How to display the multiple categories at K2 User's page?
<?php
// BEGIN: Multiple Categories for K2, by Web357
$w357_dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('k2', 'k2multiplecategories');
$k2multiplecategories = $w357_dispatcher->trigger('onK2AfterDisplayContentAdvanced', array($item));
if (!empty($k2multiplecategories) && is_array($k2multiplecategories)):
?>
<!-- Item category name -->
<div class="userItemCategory">
<span><?php echo JText::_('K2_PUBLISHED_IN'); ?></span>
<?php echo $k2multiplecategories[0]; ?>
</div>
<?php else: ?>
<!-- Item category name -->
<div class="userItemCategory">
<span><?php echo JText::_('K2_PUBLISHED_IN'); ?></span>
<a href="/<?php echo $item->category->link; ?>"><?php echo $item->category->name; ?></a>
</div>
<?php endif; // END: Multiple Categories for K2, by Web357 ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment