?
avatar smanzi
smanzi
12 Dec 2014

The problem:

In a multilingual environment "List All Categories" returns a possibly wrong articles count

Testing environment:

For other reasons I prepared a multilingual set-up that can be used to test this. It is a simple but exhaustive set-up:

  • Set up a multilingual environment for 2 languages (e.g: en-GB and it-IT)
  • Create 3 top-level content categories: one assigned to each language (counting "All" as a language)
  • Create 3 articles in each category: one assigned to each language (counting "All" as a language)
  • In both languages menu hierarchies create a menu entry for "Articles » List All Categories" (associated to the corresponding language)

Test:

In front-end visit the menu items for "List All Categories": you will see something like this:

capture

As you can see all articles in each category are accounted for.
Now visit (click on) one of the three categories.
Only 2 articles will be displayed: the one associated to the current language and the one associated to "All" languages.
Thus, the count of articles in "Articles » List All Categories" is wrong (it doesn't "filter out" the unwanted language)

The cause:

The issue is due to the model for "List categories" using JCategories::get() which doesn't have provision for filtering items based on language

Possible cures:

  • Reinvent the wheel and don't use JCategories::get() but a new similar method capable of filtering on language. (personally I don't like that...)
  • Introduce in JCategories::get() a mechanism for filtering on language. This can be done either by 1) the introduction of an option (e.g.: 'filterlang') that filters results based on the current language and the "All" language, or 2) the introduction of a new optional parameter as an array of languages that JCategories::get() should take into account
  • ... something else?

Fixing this will also have the beneficial side effect of possibly hiding categories containing only articles non-relevant for the current language (if "Empty Categories: Hide" is set).

What do you think?

N.B.: I'm personally unwilling to put my inexperienced hands on JCategories::get()'s queries and I'll need assistance for that, but I'm more then willing to help in any other possible way

avatar smanzi smanzi - open - 12 Dec 2014
avatar dgt41
dgt41 - comment - 12 Dec 2014

This is also the case if instead of list you choose blog layout?

avatar smanzi
smanzi - comment - 12 Dec 2014

I don't see a TOATAL articles count in blog layout, but, yes, 2 articles are listed for each category

avatar dgt41
dgt41 - comment - 12 Dec 2014

@smanzi you can very easily hide the number in the view, if thats not something essential...

avatar smanzi
smanzi - comment - 12 Dec 2014

@dgt41 Hello, Dimitris! Actually this issue is not directly affecting me at this time. It's nothing personal: it's about fixing a bug and doing "the right stuff".

avatar smanzi
smanzi - comment - 12 Dec 2014

... and hiding the count does not solve the issue that categories with no visible articles will be anyway listed.

avatar smanzi
smanzi - comment - 12 Dec 2014

At a first cursory look I think the language constrain should be introduced in jCategories::_load() in the subquery used to count items ('countItems' option), more or less as it is done for the 'published' option.

Can this be done as a condition in the ON clause?

avatar dgt41
dgt41 - comment - 12 Dec 2014

@smanzi You got me wrong, anyways, if you debug with your ide layouts/joomla/content/categories_default.php [this is the list view], you will see that you have the language for every item. So all it needs to be done to get this the way you want it is to have some case logic for the available languages. Hope it helps

avatar smanzi
smanzi - comment - 13 Dec 2014

Dimitris, I sincerely think it is not possible to fix this bug in view/layout...
There is a PR now: it is #5416

avatar dgt41
dgt41 - comment - 13 Dec 2014

:+1:

avatar smanzi
smanzi - comment - 13 Dec 2014

Thanks! :smile:

avatar zero-24 zero-24 - close - 13 Dec 2014
avatar infograf768
infograf768 - comment - 13 Dec 2014

Closed in favour of #5416

avatar infograf768 infograf768 - close - 13 Dec 2014
avatar infograf768 infograf768 - change - 13 Dec 2014
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-12-13 11:18:53
avatar zero-24 zero-24 - change - 7 Jul 2015
Labels Added: ?

Add a Comment

Login with GitHub to post a comment