Friday, 08 April 2022 18:02

Joomla + K2 Customization: Adding Descriptions to Tags

Written by

One of the frustrations I've encountered with the K2 extension for Joomla is the lack of a "description" when editing tags.  It allows for a description under categories, not tags.  What gives?

Here is the solution:

Procedure:

1. Open phpMyAdmin and add a new column to your k2_tags table

  • Name tag_desc
  • Type mediumtext
  • Collation utf8_general_ci
  • Attributes (empty)
  • Null Yes
  • Default NULL

2.  Modify Files:

/administrator/com_k2/views/tag/tmpl/default.php

<li>
<div class="paramLabel">
<label>Description</label>
</div>
<div class="paramValue">
<?php
$editor = JFactory::getEditor();
echo $editor->display('tag_desc', $this->row->tag_desc, '480px', '250px', '', '', false);
?>
</div>
</li>

/components/com_k2/views/itemlist/view.html.php

Line 41 

Old:
$db->setQuery('SELECT id, name FROM #__k2_tags WHERE name = '.$db->quote($tag));

New:
$db->setQuery('SELECT id, name, tag_desc FROM #__k2_tags WHERE name = '.$db->quote($tag));

~Line 312: after // Set title

Old:
$title = $tag->name;

New:

$this->assignRef('name', $tag->name);
$title = $tag->name;
$tag_desc = $tag->tag_desc;

~Line 318:

Old:
$this->assignRef('title', $title);

New:
$this->assignRef('title', $title);
$this->assignRef('tag_desc', $tag_desc);


/administrator/com_k2/models/tag.php

New line around line 41 after if row check:
$row->tag_desc = JRequest::getVar('tag_desc', '', 'post', 'string', 2);
K2 tag template override:

<p><?php echo $this->tag_desc; ?></p>

 


When you're done, the tag description will be visible on the front end like this:

ScreenShot2021 12 23at8.20.19AM 2021 12 23

Last modified on Thursday, 21 April 2022 17:30

Latest Comments

Nate Covington posted a comment in Download XMap for Joomla - All Versions Joomla
Hi, I stopped using Xmap years ago. Not sure about your particular error with Hikashop. I suggest ...
Jonathan Brain posted a comment in Download XMap for Joomla - All Versions Joomla
Got these errors with your copy of XMap for Joomla 3.0.x download when upgrading a Joomla / Hikashop...
Nate Covington posted a comment in Simple Drupal Webform (v4) PayPal Integration
@giucas - No, this is a "PayPal" thing. Most likely there IS a way for a user to pay with a guest a...
Joy Lewis posted a comment in Beware of Fraud: Web Design Scam
I had the same issue today, I'm glad I didn't respond it seemed really fishy. Thanks for getting i...
Thanks for this code! The paypal form doesn't allow guest payment (with credit card) but only via pa...

Web Design & Development

Wordpress, Drupal, Joomla
New custom websites
Bespoke themes and extensions
Redesigns, upgrades, migrations

Web Design & Development

Optimization & SEO

Let us optimize and manage your overall online presence. We offer full service monthly SEO as well as one-time projects.  

Optimization Plans & Pricing

Maintenance, Patching

White glove monthly backups, security updates, maintenance and testing for your Wordpress, Drupal, or Joomla site.

Maintenance Plans & Pricing

Stay in Touch!

Bring your web & marketing performance to the next level: monthly blog post roundup via email.  

Try it out