New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[com_content] - add categories filter to archived view #15184

Merged
merged 6 commits into from May 27, 2017
Jump to file or symbol
Failed to load files and symbols.
+6 −4
Diff settings

Always

Just for now

Viewing a subset of changes. View all

move to 1st tab

move to 1st tab
  • Loading branch information...
alikon committed Apr 10, 2017
commit 610ad34308d0aeeaa20c23282df330694799b320
@@ -81,8 +81,10 @@ protected function populateState($ordering = null, $direction = null)
*/
protected function getListQuery()
{
$params = $this->state->params;
$catids = $params->get('catid', array());
$params = $this->state->params;
$app = JFactory::getApplication('site');
$catids = $app->input->getVar('catid', array());
$catids = array_values(array_diff($catids, array('')));
$articleOrderDate = $params->get('order_date');
// Create a new query object.
@@ -123,9 +125,9 @@ protected function getListQuery()
$query->where($query->year($queryDate) . ' = ' . $year);
}
if (count($catids))
if (count($catids)>0)
{
$query->where('c.id IN (' . implode($catids, ', ') .')');
$query->where('c.id IN (' . implode($catids, ', ') . ')');

This comment has been minimized.

@Quy

Quy Apr 10, 2017

Contributor

The space can be removed in ', '.

This comment has been minimized.

@Quy

Quy Apr 10, 2017

Contributor

The order is wrong. Change implode($catids, ', ') to implode(',', $catids).

This comment has been minimized.

@rdeutz

rdeutz Apr 10, 2017

Contributor

both ways are working but you are right recommended it the other way around

This comment has been minimized.

@alikon

alikon Apr 11, 2017

Contributor

The space can be removed in ', '.

IMHO IN (val1, val2, val3, .... valn) is more portable across db's than IN (val1,val2,val3,.... valn) so the space is needed

The order is wrong. Change implode($catids, ', ') to implode(',', $catids).

from php manual :

Note:
implode() can, for historical reasons, accept its parameters in either order. For consistency with explode(), however, it may be less confusing to use the documented order of arguments.

so it's correct PHP, i'll change it to avoid confusion...

}
return $query;
ProTip! Use n and p to navigate between commits in a pull request.