Skip to content

Commit

Permalink
added tag description, (k2 introduced new feature that might have cau…
Browse files Browse the repository at this point in the history
…sed #62 , #65)
  • Loading branch information
eworkers committed Mar 23, 2024
1 parent 4a30e55 commit c03391d
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 4 deletions.
4 changes: 4 additions & 0 deletions administrator/components/com_k2/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,10 @@
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field menu="hide" name="tagDescription" type="radio" default="1" label="K2_TAG_DESCRIPTION" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field menu="hide" name="tagItemCount" type="text" default="10" size="4" label="K2_ITEM_COUNT_FOR_TAG_LISTINGS" description=""/>
<field menu="hide" name="tagItemTitle" type="radio" default="1" label="K2_ITEM_TITLE" description="">
<option value="0">K2_HIDE</option>
Expand Down
1 change: 1 addition & 0 deletions administrator/components/com_k2/install.mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ CREATE TABLE IF NOT EXISTS `#__k2_tags_xref` (
CREATE TABLE IF NOT EXISTS `#__k2_tags` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(191) NOT NULL,
`description` text NOT NULL,
`published` smallint(6) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `idx_name` (`name`),
Expand Down
7 changes: 4 additions & 3 deletions administrator/components/com_k2/tables/k2tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

class TableK2Tag extends K2Table
{
var $id = null;
var $name = null;
var $published = null;
public $id = null;
public $name = null;
public $description = '';
public $published = null;

function __construct(&$db)
{
Expand Down
8 changes: 8 additions & 0 deletions administrator/components/com_k2/views/tag/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@
<?php echo $this->lists['published']; ?>
</div>
</li>
<li>
<div class="paramLabel">
<label><?php echo Text::_('K2_DESCRIPTION'); ?></label>
</div>
<div class="paramValue">
<?php echo $this->editor; ?>
</div>
</li>
</ul>
</div>

Expand Down
6 changes: 6 additions & 0 deletions administrator/components/com_k2/views/tag/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// no direct access
defined('_JEXEC') or die;

use Joomla\CMS\Editor\Editor;
use Joomla\CMS\Filter\OutputFilter;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
Expand All @@ -30,6 +31,11 @@ public function display($tpl = null)
}
$this->row = $tag;

$editor = Factory::getApplication()->getIdentity()->getParam('editor', 'tinymce');
$wysiwyg = Editor::getInstance($editor);
$editor = $wysiwyg->display('description', $tag->description, '100%', '350px', '', '', false);
$this->editor = $editor;

$lists = array();
$lists['published'] = HTMLHelper::_('select.booleanlist', 'published', 'class="inputbox"', $tag->published);
$this->lists = $lists;
Expand Down
1 change: 1 addition & 0 deletions administrator/language/en-GB/en-GB.com_k2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ K2_TAG_CANNOT_BE_A_SINGLE_CHARACTER="Tag cannot be a single character"
K2_TAG_CANNOT_BE_EMPTY="Tag cannot be empty"
K2_TAG_CASE="Tag character case"
K2_TAG_NAME="Heading for tag listings"
K2_TAG_DESCRIPTION="Tag Description"
K2_TAG_NORMALIZATION_DESC="Enabling this option will filter all tags inserted into K2 to avoid tag duplication as much as possible. For example the tag 'Extension' or 'EXTENSION' could become lowercase 'extension'. This option already includes filters for accented Latin and Greek letters but it's easy to add your own replacement pairs below."
K2_TAG_NORMALIZATION="Tag normalization"
K2_TAG_SAVED="Tag saved"
Expand Down
5 changes: 5 additions & 0 deletions components/com_k2/templates/default/tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ class="tagView<?php if ($this->params->get('pageclass_sfx')) echo ' ' . $this->p
<h1><?php echo Text::_('K2_DISPLAYING_ITEMS_BY_TAG'); ?><?php echo $this->title; ?></h1>
<?php endif; ?>

<?php if ($this->params->get('tagDescription', 1)): ?>
<!-- Desciption for tag listings -->
<div><?php echo $this->description; ?></div>
<?php endif; ?>

<?php if ($this->params->get('tagFeedIcon', 1)): ?>
<!-- RSS feed icon -->
<div class="k2FeedIcon">
Expand Down
10 changes: 9 additions & 1 deletion components/com_k2/views/itemlist/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public function display($tpl = null)
case 'tag':
// Prevent spammers from using the tag view
$tag = Factory::getApplication()->input->getString('tag');
$db->setQuery('SELECT id, name FROM #__k2_tags WHERE name = ' . $db->quote($tag));
$db->setQuery('SELECT id, name, description FROM #__k2_tags WHERE name = ' . $db->quote($tag));
$tag = $db->loadObject();
if (!$tag || !$tag->id) {
jimport('joomla.filesystem.file');
Expand Down Expand Up @@ -315,6 +315,10 @@ public function display($tpl = null)
}
$this->title = $title;

// set description
$description = $tag->description;
$this->description = $description;

// Link
$link = K2HelperRoute::getTagRoute($tag->name);
$link = Route::_($link);
Expand Down Expand Up @@ -896,6 +900,10 @@ public function display($tpl = null)
}
}

if (!empty($tag->description)) {
$metaDesc = $tag->description;
}

$metaDesc = isset($metaDesc) ? trim($metaDesc) : '';
$document->setDescription(K2HelperUtilities::characterLimit($metaDesc, $params->get('metaDescLimit', 150)));

Expand Down
8 changes: 8 additions & 0 deletions script.k2.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,14 @@ public function update($type)
$db->execute();
}

// Tags - add description
$fields = $db->getTableColumns('#__k2_tags');
if (!array_key_exists('description', $fields)) {
$query = "ALTER TABLE #__k2_tags ADD `description` text NOT NULL";
$db->setQuery($query);
$db->execute();
}

// User groups (set first 2 user groups)
$query = "SELECT COUNT(*) FROM #__k2_user_groups";
$db->setQuery($query);
Expand Down

0 comments on commit c03391d

Please sign in to comment.