I'm using k2 to generated various tiles, which I need to filter by an additional category.

item generated in joomla

In essence, I need to get the additional categories to the front-end. I've located the PHP where this is generated:

<?php if($this->item->params->get('catItemCategory')): ?>
                    <!-- Item category name -->
                    <div class="catItemCategory">
                        <a href="<?php echo $this->item->category->link; ?>"><?php echo $this->item->category->name; ?></a>
                        // grab additional categories
 <?php endif; ?>

Is there a simple way to do this?


K2 (by default) does not allow categorizing an item into multiple categories. It's best to use tagging for that matter. However, if you really need this sort of functionality, then indeed "Additional Categories for K2" (http://extensions.joomla.org/extension/additional-categories-for-k2) is your best option.

  • I didn't want to use tagging as it didn't scale well. I was using 'Additional Categories for K2' at this stage, and have implemented the filters by parsing the additional classes to a data-size. Thanks for your input!
    – Tom Reeves
    Sep 30 '15 at 13:35

For anyone who is struggling with this, I had to go through the 'additional categories' extension. Grabbing the additional categories can be achieved by the following:

// Stringify array of subcategories (generated in k2additionalcategories.php)
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin ('k2');
$additional_category_links=$dispatcher->trigger('onK2AfterLinkCategoryPublish', array($this->item->id));
$subcategorystring = implode (" ", $additional_category_links);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.