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

Filtering categories by languade #5756

Closed
wants to merge 2 commits into from
Closed

Conversation

toslan
Copy link

@toslan toslan commented Jan 16, 2015

Fix issue described here: #5734

@toslan
Copy link
Author

toslan commented Jan 16, 2015

I suggest this patch to solve issues
#5734
#5740

if (JLanguageMultilang::isEnabled())
{
$query->where('c.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the tab after } for Travis to succeed ;-)
(no space at end of a line)

@cyrezdev
Copy link
Contributor

@test success!

Before PR, categories were not filtered by language.

PR tested with multi-language enabled, and with those settings :

  • CAT_LANG1
    • - SUB_CAT_LANG1
    • - SUB_CAT_LANG2
    • - - SUB_SUB_CAT_LANG1
    • - SUB_CAT_LANG3
  • CAT_LANG2
    • - SUB_CAT_LANG1
    • - SUB_CAT_LANG3

Menus (Type: category list or category blog) :

  1. Menu LANG_1 -> CAT_LANG1
  2. Menu LANG_2 -> CAT_LANG2
  3. Menu LANG3 -> CAT_LANG2

Results with PR :

  1. CAT_LANG1 + SUB_CAT_LANG1
  2. CAT_LANG2 (no subcategory displayed each time a parent is not in current language)
  3. error 404 "Category not found"

So, all is good! 👍
Note that about 3, i will check this week-end (or if another person is looking at it already...) if possible to add a checking when saving a menu, to prevent to be able to save a menu if menu language is not the same as the category's language selected.

Cyril

@@ -241,6 +241,11 @@ protected function _load($id)
{
$query->where('c.published = 1');
}
// Filter category by language
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will just add here before a new line, to separate the filter by language from the filter by state ;-)

@infograf768
Copy link
Member

Will test later.

@zero-24
Copy link
Contributor

zero-24 commented Jan 19, 2015

New PR by @toslan #5817

@toslan toslan deleted the patch-1 branch January 19, 2015 12:26
@toslan
Copy link
Author

toslan commented Jan 19, 2015

I came across with another issue related to category language filter. The Language switcher module uses path helper to compute associated URLs. Since inactive languages are now filtered out the URLs for category views cannot be computed this way. Moreover path helper always loads complete category views for all languages which is wasteful because users usually do not switch to different languages while browsing.
I suggest PR #5817 to fix this issue. It uses patch #5756 (which is now closed) and some more files patched. No more category path helper called. Category objects for inactive languages are not loaded anymore.

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

Successfully merging this pull request may close these issues.

None yet

5 participants