article
, category
, tag
or menu
Association
button.Joomla 3.9.15, PHP 7.2.26, MySQL 5.5.64
I now worked on a site that has more than 300 categories, more than 5000 articles and I am adding a new language on the website. I believe that if a specific language was selected, then categories should be displayed only in a specific language in this field. It is very difficult to constantly flip through all these categories and accidentally not click on another language, especially if the category name does not have a translation.
for example: categories such as iOS and Android in any language will be written in English and this makes it difficult to search and choose. Not all categories can be translated into another language.
Labels |
Added:
?
|
@infograf768 We would have to re-populate or modify the category selection dropdown list after each change of the language. Am not sure either if we can do that. Or does showon also work for the option values of lists? That would be really cool, but I don't think it does. Will not help anyway as we can't add showon dynamically, I guess.
We would have to re-populate the category selection dropdown list after each change of the language. Am not sure either if we can do that.
In Joomla, this is already provided for articles. If during editing two articles you click on button Change Target
, then we will see only articles for a particular language, and we will not see articles for another language. I think that this can also be done for categories, so that when choosing a particular language, only those categories that correspond to that language are shown. I think this is have the logic and rightly so.
@infograf768 I do not have to choose between articles for different languages, I see in this window only articles for a particular selected language.
I am not a developer, but I think it is possible to do this using javascript or similar technology. This will help a lot for editing articles and this will be the right decision.
@sanek4life I see. But as far as I understand you mean with "Editing 2 articles" not the normal article edit view but the comparison view of the Multilingual Associations Component, right?
@sanek4life I see. But as far as I understand you mean with "Editing 2 articles" not the normal article edit view but the comparison view of the Multilingual Associations Component, right?
Yes. look at my first comment and first screenshot.
there are many articles in one language on my website. and now I am translating these articles into another language and I constantly see a mixture of categories for different languages in this field.
Ah yes ... sometimes I am a bit slow .. thanks for clarification.
The situation is very different.
The modal uses the forcedLanguage
parameter (whether using Target
in com_associations or using Select
when editing an item).
In the Category field, we have a list of categories which is not filtered BUT the assigned language for each category IS displayed.
In the OP original screenshot one can see for example
Category (en-uk) (en-GB)
where (en-GB)
has been added by code to specify which language is assigned to this category.
So, if a category has the same name in en-GB or ru-RU, it will show and there is no confusion.
One will get iOS (en-GB
and iOS (ru-RU)
.
Is it possible, when editing articles, to already filter the category list in com_associations depending on the Target language (knowing that only both categories set to ALL languages and the Target language should display) is a real question.
And, as I said, not sure we can.
If we could then it should also work (when the language filter is on) when editing a simple article via com_content, once the article language is saved and it is not set to ALL languages.
BTW, that field is called categoryedit
.
File is /administrator/components/com_categories/models/fields/categoryedit.php
Language settings on my website, if the screenshots confused you:
I use only 2 languages on my website: en-GB
and ru-RU
I changed the flag for language en-GB
. And I shortened the names from en-GB
to en
& from ru-RU
to ru
.
I followed @google’s recommendations for the correct language name on my website: https://support.google.com/webmasters/answer/189077
Supported language/region codes
The value of the hreflang
attribute identifies the language (in ISO 639-1 format) and optionally a region (in ISO 3166-1 Alpha 2 format) of an alternate URL. (The language need not be related to the region.) For example:
de
: German language content, independent of regionen-GB
: English language content, for GB usersde-ES
: German language content, for users in Spainbe
: Belarusian language, independent of region (not Belgium French)nl-be
: Dutch for Belgiumfr-be
: French for BelgiumFor language script variations, the proper script is derived from the country. For example, when using zh-TW for users in Taiwan, the language script is automatically derived (in this example: Chinese-Traditional). You can also specify the script itself explicitly using ISO 15924, like this:
zh-Hant
: Chinese (Traditional)zh-Hans
: Chinese (Simplified)Alternatively, you can also specify a combination of script and region—for example, use zh-Hans-TW
to specify Chinese (Simplified) for Taiwanese users.
This is unrelated.
I am now looking if I can filter the categories.
be patient please.
Please test replacing the file /administrator/components/com_categories/models/fields/categoryedit.php
by this one (after unzipping it);
@richard67
The diff is
diff --git a/administrator/components/com_categories/models/fields/categoryedit.php b/administrator/components/com_categories/models/fields/categoryedit.php
index 96bc7bd..8a68505 100644
--- a/administrator/components/com_categories/models/fields/categoryedit.php
+++ b/administrator/components/com_categories/models/fields/categoryedit.php
@@ -192,4 +192,13 @@
}
+ // When multilang is enabled, filter categories depending on item language
+ $extensionItemLanguage = $this->form->getValue('language');
+
+ if (JFactory::getApplication()->isClient('administrator') && JLanguageMultilang::isEnabled()
+ && $extensionItemLanguage && $extensionItemLanguage != '*')
+ {
+ $query->where($db->quoteName('a.language') . ' IN (' . $db->quote($extensionItemLanguage) . ',' . $db->quote('*') . ')');
+ }
+
// Filter on the published state
$query->where('a.published IN (' . implode(',', ArrayHelper::toInteger($published)) . ')');
I think it should be BC. Can you test?
Hmm
@richard67
Indeed, this would work for a new article but you are right
@infograf768 We would have to re-populate or modify the category selection dropdown list after each change of the language. Am not sure either if we can do that. Or does showon also work for the option values of lists? That would be really cool, but I don't think it does. Will not help anyway as we can't add showon dynamically, I guess.
So, it is possible to use this when associations are at state and language is already defined but changing language in a pure edit (for article as example), would not work...
Trying to figure how to solve this.
Anyway the patch should only be useful in com_associations and has to be modified (if possible)
No idea why it does not work for you. cache issue? file not really replaced?
@MostafaHamedAbdelmasoud
You are right. If the language is not saved yet it does not work.
it is working now like a charm
Anyway the patch should only be useful in com_associations and has to be modified (if possible)
No idea why it does not work for you. cache issue? file not really replaced?
do you mean this feature should only work in (com_associations) option and shouldn't work in any option else, like (com_content) option....etc?
My patch is not good at all.
So we need to limit it to com_associations and make it work also for new item.
Will try to find a solution, but not sure...
1- yes we can limit it to com_associations, i will find a solution too.
2- and you are right....we can't make it for a new item like new article as we want to select language first..... but we can handle it from jquery select the language first then show categories part depending on this language.
.
i want to work on it too; to get familiar with code and know how the components connect with each others
Status | New | ⇒ | Confirmed |
Labels |
Added:
No Code Attached Yet
bug
Removed: ? |
will look tomorrow but I am not sure we can solve this.