M
M
Mikhail Mirgorodsky2019-12-09 13:33:50
Joomla
Mikhail Mirgorodsky, 2019-12-09 13:33:50

How to display description in K2 joomla material?

joomla 3.9
K2 2.9
I display a material that has its own description and keywords, but displays the description of the material from the category in which it lies. Tell me how to fix it? Googled, found one answer, marked as solved, but for some reason the solution does not suit me.
Z.Y. In the K2 category itself, description is not specified, but is specified for the menu item in which the category is displayed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Mirgorodsky, 2019-12-09
@PiZZaDoXa

I'll answer myself, my solution is the following:
in the file /components/com_k2/views/item/view.html.php
somewhere near line 420, we find the code responsible for checking and outputting description. It looks like this:

if ($params->get('menu-meta_description')) {
$document->setDescription($params->get('menu-meta_description'));
}

if ($params->get('menu-meta_keywords')) {
$document->setMetadata('keywords', $params->get('menu-meta_keywords'));
}

We change it to:
if ($params->get('menu-meta_description') && (!$document->setDescription($item->metadesc))) {
$document->setDescription($params->get('menu-meta_description'));
}

if ($params->get('menu-meta_keywords') && (!$document->setMetadata('keywords', $item->metakey))) {
$document->setMetadata('keywords', $params->get('menu-meta_keywords'));
}

Do not forget to clear the cache of our joomla, of course, if caching is enabled.
Good luck!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question