Sorting Drop-down broken for Multilingual Fields on Front-End

5 views
Skip to first unread message

Dmitry A.

unread,
May 15, 2011, 11:06:50 PM5/15/11
to in-port...@googlegroups.com
Hi guys,


In latest In-Portal 5.1.2, I have came across a small bug (on Front-End) in sorting drop-down for Multilingual fields. Try sorting your Links by Name A-Z and then Name Z-A. The actual sorting works well, but the drop-down which shows the direction is not due to some minor bug. 

Here is a link to original Multilingual field sorting sometimes doesn't work discussion and 859: Multilingual field sorting sometimes doesn't work task where we were talking about and fixing one issue, but have a bug in the implementation.

The problem is that  method is used by AddOrderField and SortingSelected methods where 1st is used to be put in SQL when 2nd to be used in the tag processor.

function getMLSortField($field)
{
$table_name = '`' . $this->TableName . '`';
$lang = $this->Application->GetVar('m_lang');
$primary_lang = $this->Application->GetDefaultLanguageId();

$ret = 'IF(COALESCE(%1$s.l' . $lang . '_' . $field . ', ""), %1$s.l' . $lang . '_' . $field . ', %1$s.l' . $primary_lang . '_' . $field . ')';

return sprintf($ret, $table_name);
}


It breaks due to $ret = 'IF(COALESCE(%1$s.l' . $lang . '_' . $field . ', ""), %1$s.l' . $lang . '_' . $field . ', %1$s.l' . $primary_lang . '_' . $field . ')'; part when it's getting passed to SortingSelected for comparison. 

I guess it brings up the question whether we really should count in the Language Prefix for in SortingSelected($params), but instead just work with it as Name|desc and Description|desc without trying to match l1_Name|desc = l1_Name|desc in the check for Multilingual fields? Like here:

return strtolower($current_sorting) == strtolower($params['sorting']) ? $params['selected'] : '';


I have attached a simple patch which might not be the optimal solution, but has been tested by me well.


Alex what you think?


DA
Sorting-Drop-down-broken-for-Multilingual-Fields.patch

Alexander Obuhovich

unread,
May 16, 2011, 4:10:04 AM5/16/11
to in-port...@googlegroups.com
Task: http://tracker.in-portal.org/view.php?id=1052

I've used alternative approach, where I totally ignored language prefix (e.g. "l1_"). See/test patch attached.


--
You received this message because you are subscribed to the Google Groups "In-Portal Bugs Team" group.
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.



--
Best Regards,

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

Dmitry A.

unread,
May 16, 2011, 8:37:04 AM5/16/11
to in-port...@googlegroups.com
Thanks Alex - Tested good!

Initially I had the same idea of removing the Language Prefix, but then though what if someone has used l1_Name|desc or so in the templates :) I guess it's too bad for him.


DA

Alexander Obuhovich

unread,
May 16, 2011, 9:38:46 AM5/16/11
to in-port...@googlegroups.com
Yes, we don't use "l1_Name|desc" in templates. This way if someone had sorting by Name field on 1st language and then switched to 2nd language, then that sorting will be adjusted to sort by Name field on 2nd language automatically.

It's safe to presume, that on Front-end sorting will be by current language only. I don'y see any point of sorting by Russian language, while viewing on English language.


This make some sense in Admin Console, where sorting setting is kept in session and you really can sort by English translation, while viewing on Russian language.




DA

--
You received this message because you are subscribed to the Google Groups "In-Portal Bugs Team" group.
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,
May 18, 2011, 3:12:16 PM5/18/11
to in-port...@googlegroups.com
Thanks for reviewing Alex.

Agreed on removing that Language Prefix there!


DA
Reply all
Reply to author
Forward
0 new messages