Hello everyone !

I have a file:

templates/my_template/html/layouts/joomla/content/intro_image.php 

I need to insert into it a code that would display the name of the category which includes the material whose intro image is displayed on the website + add the date of publication of this material ...

How to do it - I do not understand ... I tried in different ways:

 $this->category->text $this->category->title 

and a bunch of different type codes:

 $title = $this->escape($displayData['item']->category_title); 

Nothing works ...

Can someone tell me how to do this?

Thank you in advance for the answers !

  • materials are output through the module? or through a category blog template? or how? - boneskhv
  • Through the blog template: templates / my_template / html / layouts / joomla / content / intro_image.php - Alexon Classic
  • in this case, you need to overload another file /templates/my_template/com_content/category/blog_item.php - boneskhv
  • there the intro_image of the material is already obtained through $ var = json_decode ($ this-> item-> images), it will be in $ var-> intro_image. And the name of the category, if my memory does not change, is displayed there like this: $ this-> item-> category_title - boneskhv pm
  • to mine even the intro_image there is already initially available in $ images-> image_intro (but this is not accurate). In any case, you can use var_dump and see everything where it is - boneskhv

1 answer 1

It turned out that you can still do without a query to the database ...

It was enough in

 templates/my_template/html/layouts/joomla/content/info_block 

create 2 files:

1) category_title.php, in which to register it:

  <?php defined('JPATH_BASE') or die; echo $this->escape($displayData['item']->category_title); ?> 

2) publish_date_no_html.php, in which to register it:

  <?php defined('JPATH_BASE') or die; echo JHtml::_('date', $displayData['item']->publish_up, JText::_('DATE_FORMAT_LC2')); ?> 

and in blog_item.php add:

 $cat_name = JLayoutHelper::render('joomla.content.info_block.category_title', array('item' => $this->item)); $art_publish_date = JLayoutHelper::render('joomla.content.info_block.publish_date_no_html', array('item' => $this->item)); JRequest::setVar('cat_name', $cat_name, 'post'); //задаем глобальную переменную JRequest::setVar('art_publish_date', $art_publish_date, 'post'); //задаем глобальную переменную 

and already in intro_image.php, add this:

 $cat_name = JRequest::getVar('cat_name', '', 'post'); //считываем глобальную переменную $art_publish_date = JRequest::getVar('art_publish_date', '', 'post'); //считываем глобальную переменную 

and in the right place, through echo to display the category name and the date of publication of the material ...