Skip to content
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

Multilingual: possible error in articles count with "List all categories" #5412

Closed
smanzi opened this issue Dec 12, 2014 · 11 comments
Closed

Comments

@smanzi
Copy link

smanzi commented Dec 12, 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

@dgrammatiko
Copy link
Contributor

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

@smanzi
Copy link
Author

smanzi commented Dec 12, 2014

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

@dgrammatiko
Copy link
Contributor

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

@smanzi
Copy link
Author

smanzi commented Dec 12, 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".

@smanzi
Copy link
Author

smanzi commented Dec 12, 2014

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

@smanzi
Copy link
Author

smanzi commented Dec 12, 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?

@dgrammatiko
Copy link
Contributor

@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

@smanzi
Copy link
Author

smanzi commented Dec 13, 2014

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

@dgrammatiko
Copy link
Contributor

👍

@smanzi
Copy link
Author

smanzi commented Dec 13, 2014

Thanks! 😄

@infograf768
Copy link
Member

Closed in favour of #5416

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants