I have tried to search on every Joomla site to find a solution but haven't found a proper result yet.
I have created this custom module for my page and I need to display the "corrent" category title. I know I figured out that the original joomla com_content
shows the corrent category by using this code:
defined('JPATH_BASE') or die;
?>
<div class="category-name">
<?php $title = $this->escape($displayData['item']->category_title); ?>
<?php if ($displayData['params']->get('link_category') && $displayData['item']->catslug) : ?>
<?php echo '<a href="' . JRoute::_(ContentHelperRoute::getCategoryRoute($displayData['item']->catslug)) . '" itemprop="genre" data-toggle="tooltip"><i class="fa fa-folder-open-o"></i> ' . $title . '</a>'; ?>
<?php else : ?>
<?php echo '<span itemprop="genre" itemprop="genre" data-toggle="tooltip" title="' . JText::_('COM_CONTENT_CONTENT_TYPE_CATEGORY') . '">' . $title . '</span>'; ?>
<?php endif; ?>
</div>
I tried to copy/paste it to my module, but it didn't work. I figured out I need to first import Joomla component helper. something like this:
jimport('joomla.application.component.helper');
$content_params = JComponentHelper::getParams( 'com_content' );
$show_category = $content_params->get( 'show_category' );
and now I need to display the category title, but I dont know how to do that, can anyone please help me?