Welcome,
Guest
.
Please
login
or
register
.
Did you miss your
activation email
?
News:
IOS Hotels
and
IOS Rentals
online booking systems for Elxis CMS.
Home
Help
Login
Register
Elxis CMS Forum
»
Support
»
General
(Moderators:
Ivan Trebješanin
,
Farhad Sakhaei
) »
Order tag listing by correct language titles?
« previous
next »
Print
Pages: [
1
]
Author
Topic: Order tag listing by correct language titles? (Read 2773 times)
seadhna
Hero Member
Posts: 507
Order tag listing by correct language titles?
«
on:
June 07, 2021, 16:00:35 »
When we tag articles in a second language and then visit the tag listing on that language version of the website, the articles are ordered by the default language spelling, not by the language we are viewing. Is it possible to change this?
e.g. imagine four articles named in English (default language) as 1) Ethiopia 2) Uzbekistan 3) Zambia 4) Zimbabwe
Then on a DE version of the site, we name the articles as 1) Äthiopien 2) Usbekistan 3) Sambia 4) Simbabwe
Now we tag all four articles in English as 'countries' and in German as 'länder'. If we visit:
www.example.org/tags.html?tag=countries
we can see the four articles ordered alphabetically: 1) Ethiopia 2) Uzbekistan 3) Zambia 4) Zimbabwe
However, if we visit the tag page in DE:
www.example.org/de/tags.html?tag=l
änder
the four articles are not listed in correct alphabetical order - instead they are listed according to the English titles.
Articles SHOULD be ordered: 1) Äthiopien 2) Sambia 3) Simbabwe 4) Usbekistan
but they are not. They ARE ordered: 1) Äthiopien 2) Usbekistan 3) Sambia 4) Simbabwe
which doesn't make sense. Is there a way to make sure tag listings are ordered alphabetically in the correct order for that language?
Logged
seadhna
Hero Member
Posts: 507
Re: Order tag listing by correct language titles?
«
Reply #1 on:
June 07, 2021, 16:10:03 »
I just realized I stated this incorrectly: tag listings are ordered by DATE. Is it possible to order a tag listing alphabetically instead?
I could date the articles below so that they appear in correct alphabetical order in English, but the order won't change in other languages...
Logged
datahell
Elxis Team
Hero Member
Posts: 10356
Re: Order tag listing by correct language titles?
«
Reply #2 on:
June 07, 2021, 20:01:49 »
The ordering method is fixed. They are ordered by creation date in descending order (
newer first
).
It is not that easy to create a perfect ordering in mixed multilingual strings. This is because PHP has a problem here and to bypass it you need either to develop a special order class or use PHP collator which is not enabled by default in PHP. I will tell you what to do but
it will not work perfect on mixed content
because the ordering method does binary comparisons, not string comparisons.
Open this file:
components/com_content/models/content.model.php
Go to lines 548-549, you will find this:
unset($articles);
return $rows;
Add between them a new line so at the end you will have this:
unset($articles);
uasort($rows, array('contentModel', 'customOrderByName'));
return $rows;
One line below and after the closing bracket "}" add this method:
public static function customOrderByName($a, $b) {
return strcmp($a->title, $b->title);
}
In English it works fine. For Greek language the result is that it displays the order correctly but in reverse order. This is because the comparison function works in binary mode. I believe the same will happen in French, German, Russian, Chinese, and any other language that has multi-byte characters over the ASCII ones.
My advice is not to change it.
It is better to order the articles in tags page by date rather than by title. The newer articles will be displayed first and this is better.
«
Last Edit: June 07, 2021, 20:11:34 by datahell
»
Logged
Elxis Team
|
Is Open Source
|
IOS Rentals | IOS AERO
seadhna
Hero Member
Posts: 507
Re: Order tag listing by correct language titles?
«
Reply #3 on:
June 08, 2021, 12:41:37 »
Hmm, yes, it works in English but not for the German version. Ok, I follow your advice and don't change it. Thanks!
Logged
Print
Pages: [
1
]
« previous
next »
Elxis CMS Forum
»
Support
»
General
(Moderators:
Ivan Trebješanin
,
Farhad Sakhaei
) »
Order tag listing by correct language titles?