Skip to content

Commit

Permalink
Support multiple tags filtering in Administrator ContentModelFeatured
Browse files Browse the repository at this point in the history
Allow featured articles to be filtered by multiple tags in Administrator
  • Loading branch information
jrseliga committed Dec 20, 2014
1 parent 8baa472 commit 74d12ee
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
13 changes: 12 additions & 1 deletion administrator/components/com_content/models/featured.php
Expand Up @@ -79,7 +79,7 @@ protected function getListQuery($resolveFKs = true)
$query->select(
$this->getState(
'list.select',
'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid, a.state, a.access, a.created, a.hits,' .
'DISTINCT a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid, a.state, a.access, a.created, a.hits,' .
'a.featured, a.language, a.created_by_alias, a.publish_up, a.publish_down'
)
);
Expand Down Expand Up @@ -196,6 +196,17 @@ protected function getListQuery($resolveFKs = true)
. ' AND ' . $db->quoteName('tagmap.type_alias') . ' = ' . $db->quote('com_content.article')
);
}
elseif (is_array($tagId))
{
JArrayHelper::toInteger($tagId);
$tagId = implode(',', $tagId);
$query->where($db->quoteName('tagmap.tag_id') . ' IN (' . $tagId . ')')
->join(
'LEFT', $db->quoteName('#__contentitem_tag_map', 'tagmap')
. ' ON ' . $db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
. ' AND ' . $db->quoteName('tagmap.type_alias') . ' = ' . $db->quote('com_content.article')
);
}

// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering', 'a.title')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
Expand Down
Expand Up @@ -73,11 +73,12 @@
name="tag"
type="tag"
mode="nested"
multiple="true"
class="advancedTags"
label="JOPTION_FILTER_TAG"
description="JOPTION_FILTER_TAG_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_TAG</option>
</field>
</fields>
<fields name="list">
Expand Down
Expand Up @@ -13,6 +13,7 @@

JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', '.advancedTags', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_TAG')));
JHtml::_('formbehavior.chosen', 'select');

$user = JFactory::getUser();
Expand Down

0 comments on commit 74d12ee

Please sign in to comment.