Multilingual field sorting not working in some cases on 5.2.0-RC1

8 views
Skip to first unread message

Alexander Obuhovich

unread,
Jul 9, 2012, 2:08:44 PM7/9/12
to In-Portal Bugs
In-Portal can operate on single record (via kDBItem class) and on lists/grids (via kDBList class). For lists additionally sorting can be specified in following ways:
  • via "ListSortings -> ForcedSorting" setting (in unit config), which defines sorting that is always in effect and can't be changed by user (usually by Priority field)
  • via "ListSortings -> Sorting" setting (in unit config), which defines default sorting for a list of none was set by user
  • via configuration settings from SystemSettings database table, which is same as sorting above, but can be changed any time without a need to edit PHP files of that unit config
  • via kDBList::AddOrderField method call from PHP, which accompanies default sorting (added after/before it), that comes all places described above
All sortings of described above are added via kDBList::AddOrderField method eventually and he does 2 things:
  • if field isn't translatable then leave it's name as is
  • if field is translatable and language is indicated (e.g. l2_Name), then we sort by this field value only
  • if field is translatable and language isn't indicated (e.g. Name), then we sort by this field value with fallback to primary language
All seems to be working normally until we start to work with multilingual fields. With multilingual fields we have field value split across N fields (1 field for each language).

Method kDBList::AddOrderField can handle all cases, but all mentions of translatable fields in unit config are pre-processed by kMultiLanguage formatter resulting in "Name" in "ListSortings" setting to be replaced with "l1_Name" and this way disabling fallback to primary language.


I think, that this is incorrect behavior, especially for users, who don't usually enter data on non-primary language in hopes, that primary language value fallback will kick-in in all places and save the day.


Guys, what do you think?


--
Best Regards,

http://www.in-portal.com
http://www.alex-time.com

Dmitry A.

unread,
Jul 17, 2012, 12:55:20 AM7/17/12
to in-port...@googlegroups.com
Hi Alex,


Sorry for delay.

I am not sure I am following you on WHY "resulting in "Name" in "ListSortings" setting to be replaced with "l1_Name" and this way disabling fallback to primary language." Do you mean it always puts "l1_" prefix there no matter on what ID of Primary Language is?

DA

Alexander Obuhovich

unread,
Jul 17, 2012, 3:08:44 AM7/17/12
to in-port...@googlegroups.com
It always puts "l<N>_" prefix, where <N> is current language. That's not a problem. Problem is that is no data on <N> language, then we:
  • display data from primary language - it's good
  • sort by missing data from current language - that's bad



DA

--
You received this message because you are subscribed to the Google Groups "In-Portal Bugs Team" group.
To view this discussion on the web visit https://groups.google.com/d/msg/in-portal-bugs/-/5W587xXRlWUJ.
To post to this group, send email to in-port...@googlegroups.com.
To unsubscribe from this group, send email to in-portal-bug...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/in-portal-bugs?hl=en.

Dmitry A.

unread,
Jul 18, 2012, 12:14:02 AM7/18/12
to in-port...@googlegroups.com
In other words, you are saying that we don't have the same adaptive mechanism in Sorting Data from mult. fields as we do in Showing it.

So sort field would look something like this?

ORDER BY IF(l2_Name != '' OR ISNULL(l2_Name), l2_Name,  l1_Name) ASC ?


DA 

Alexander Obuhovich

unread,
Jul 18, 2012, 2:56:45 AM7/18/12
to in-port...@googlegroups.com
NULL value is considered as empty value and your expression can be rewritten to:

ORDER BY IF(COALESCE(l2_Name, '') != '', l2_Name, l1_Name) ASC.




DA 

--
You received this message because you are subscribed to the Google Groups "In-Portal Bugs Team" group.
To view this discussion on the web visit https://groups.google.com/d/msg/in-portal-bugs/-/JcremXNze94J.

To post to this group, send email to in-port...@googlegroups.com.
To unsubscribe from this group, send email to in-portal-bug...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/in-portal-bugs?hl=en.

Dmitry A.

unread,
Jul 22, 2012, 2:25:40 AM7/22/12
to in-port...@googlegroups.com
Agreed!

Please proceed with the task.

DA

Alexander Obuhovich

unread,
Jul 22, 2012, 9:57:11 AM7/22/12
to in-port...@googlegroups.com
Here is the task: http://tracker.in-portal.org/view.php?id=1366

Ready for testing.



DA

--
You received this message because you are subscribed to the Google Groups "In-Portal Bugs Team" group.
To view this discussion on the web visit https://groups.google.com/d/msg/in-portal-bugs/-/Wwh4s5rZzf4J.

To post to this group, send email to in-port...@googlegroups.com.
To unsubscribe from this group, send email to in-portal-bug...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/in-portal-bugs?hl=en.

Dmitry A.

unread,
Jul 23, 2012, 12:21:34 AM7/23/12
to in-port...@googlegroups.com
It would be good to know the test case or places which had this not working before the patch.

Pretty hard to just guess it.

DA

Alexander Obuhovich

unread,
Jul 23, 2012, 7:03:55 AM7/23/12
to in-port...@googlegroups.com
Here you go:
  1. add 2nd language to website, but don't select "copy translations from English" option;
  2. take any unit that you like, that have multilingual fields (except ones, that allow sorting to be specified in configuration, like categories, links, etc.);
  3. add some records to the chosen unit and type multilingual field values only on primary language;
  4. in unit config of chosen unit (or by other feasible means) set sorting to be happening by that multilingual field (without specifying "lN_" prefix of course);
  5. on Front-End output data (that you've just entered) from that unit and notice how it's sorted;
  6. switch to 2nd language
Without a patch data will be sorted at random, but with a patch it will be sorted as on primary language since it's a fallback language being used in this case.




DA

--
You received this message because you are subscribed to the Google Groups "In-Portal Bugs Team" group.
To view this discussion on the web visit https://groups.google.com/d/msg/in-portal-bugs/-/z-rscerThOMJ.

To post to this group, send email to in-port...@googlegroups.com.
To unsubscribe from this group, send email to in-portal-bug...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/in-portal-bugs?hl=en.
Reply all
Reply to author
Forward
0 new messages