Advertisement

Articles model can not filter tags[fixed]

Did you find a bug in Joomla! 3.x but aren't sure? This forum is the place to help figure out if the problem is a bug and how to report it. If you are an experienced Joomla! user and are certain that you have found a bug please use the Bug Tracker to submit your issue.
This forum is for discussion about bugs and to get help with reporting them to the Bug Tracker: https://issues.joomla.org

Moderator: ooffick

Forum rules
Please use the official Bug Tracker to report a bug: https://issues.joomla.org
Locked
Zjmainstay
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Fri Jan 13, 2012 2:35 am
Contact:

Articles model can not filter tags[fixed]

Post by Zjmainstay » Fri Mar 14, 2014 6:14 am

maybe ContentModelArticles can add

Code: Select all

// Filter by tags.
$tagIds = (array)$this->getState('filter.tag');

if (!empty($tagIds))
{
    $query->where($db->quoteName('tagmap.tag_id') . ' IN( ' . implode(',', array_values($tagIds)) . ')')
        ->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')
        );
}
in getListQuery method to filter tags articles.

Otherwise, select result should add

Code: Select all

distinct
to filter articles when one article has two or more tags to filter.

Code: Select all

$query->select(
    $this->getState(
        'list.select',
        'distinct a.id, a.title, a.alias, a.introtext, a.fulltext, ' .
            'a.checked_out, a.checked_out_time, ' .
            'a.catid, a.created, a.created_by, a.created_by_alias, ' .
            // Use created if modified is 0
            'CASE WHEN a.modified = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.modified END as modified, ' .
            'a.modified_by, uam.name as modified_by_name,' .
            // Use created if publish_up is 0
            'CASE WHEN a.publish_up = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_up END as publish_up,' .
            'a.publish_down, a.images, a.urls, a.attribs, a.metadata, a.metakey, a.metadesc, a.access, ' .
            'a.hits, a.xreference, a.featured,' . ' ' . $query->length('a.fulltext') . ' AS readmore'
    )
);

=============

Code: Select all

<field name="tagids" type="tag" class="" label="TAGS" description="DESC" mode="nested" field="id" parent="parent" multiple="true"></field>
can be use in xml to enable tags to select to filter articles.
mod_news_show_sp2-add tags filter.zip
You do not have the required permissions to view the files attached to this post.
个人博客:http://zjmainstay.cn

Advertisement
Advertisement
Locked

Return to “Joomla! 3.x Bug Reporting”