-
AuthorPosts
-
thesdhotel Friend
thesdhotel
- Join date:
- March 2017
- Posts:
- 90
- Downloads:
- 25
- Uploads:
- 1
- Thanks:
- 31
- Thanked:
- 22 times in 20 posts
September 25, 2017 at 3:30 pm #1063967When you try to sort for a Text Field that has Number Values in it, the sorting doesn’t understand it and doesn’t order the items correctly.
For example. In Joomla Content Custom Fields, I’m using a Text Field called "Price". This "Price" field, of course, only contains number values, and it contains values of any amout of digits (it can be for example from 8000 to 1250000).
When sorting these values, Megafilter doesn’t take into consideration the amount of digits and just sorts them alphabetically.
It orders them like this:
1000
10000
100000
2000
20000
200000
3000
30000
300000
etc..It should instead order them like this:
1000
2000
3000
10000
20000
30000
100000
200000
300000You know what I mean? Could you please fix this?
- This topic was modified 7 years, 1 month ago by thesdhotel.
Luna Garden ModeratorLuna Garden
- Join date:
- July 2011
- Posts:
- 2617
- Downloads:
- 80
- Uploads:
- 96
- Thanks:
- 78
- Thanked:
- 453 times in 425 posts
September 26, 2017 at 9:09 am #1064144thesdhotel Friendthesdhotel
- Join date:
- March 2017
- Posts:
- 90
- Downloads:
- 25
- Uploads:
- 1
- Thanks:
- 31
- Thanked:
- 22 times in 20 posts
September 27, 2017 at 8:15 am #1064400I found out that this bug gets fixed after fixing this other problem at this link: https://www.joomlart.com/forums/topic/extra-space-at-the-end-of-values-of-field-type-texteditortextareaurl/
So maybe you already have that fixed at your end and that’s why you can’t reproduce it?
After applying that fix for that other problem, this problem gets fixed too.
- This reply was modified 7 years, 1 month ago by thesdhotel.
October 4, 2017 at 5:28 am #1065646Hi thesdhotel,
Is it really fixed at yours?
I’ve made the fix from the link, nothing changes to me. The problem of the order has not been completely solved.
Perhaps they can better keep the order of custom fields? These are finally also interchangeable within the custom fields.
Mr.Cat ModeratorMr.Cat
- Join date:
- December 2016
- Posts:
- 270
- Downloads:
- 24
- Uploads:
- 69
- Thanks:
- 58
- Thanked:
- 53 times in 50 posts
October 4, 2017 at 7:26 am #1065692Perhaps they can better keep the order of custom fields? These are finally also interchangeable within the custom fields.
For now, there is no way to make filter field order like at backend, but here is a trick to make it works with your issue.
Open file
/components/com_jamegafilter/assets/js/megafilter.js
Go to line 652 and replace the content on the scope with this
var order = (fgroup.options.order.toUpperCase() == 'DESC') ? -1 : 1; keys.sort(function (a, b) { var v1, v2, s1, s2; v1 = fgroup.getItem(a).options.frontend_value; v2 = fgroup.getItem(b).options.frontend_value; s1 = Number(v1.split(' ')[0]); s2 = Number(v2.split(' ')[0]); if (s1 && s2) { return s1 > s2 ? 1 : -1; } else { return v1.localeCompare(v2) * order; } }); var _items = {}; keys.forEach(function (id) { _items[id] = fgroup.getItem(id); }); fgroup.items = _items;
Like attachment below
Regards
thesdhotel Friendthesdhotel
- Join date:
- March 2017
- Posts:
- 90
- Downloads:
- 25
- Uploads:
- 1
- Thanks:
- 31
- Thanked:
- 22 times in 20 posts
thesdhotel Friendthesdhotel
- Join date:
- March 2017
- Posts:
- 90
- Downloads:
- 25
- Uploads:
- 1
- Thanks:
- 31
- Thanked:
- 22 times in 20 posts
October 30, 2017 at 11:11 am #1070952I noticed this is still a problem with numbers that have decimal values. See example below:
The sorting of 12.88, 13.05 and 13.40 shouldn’t be in that position.
Mr.Cat ModeratorMr.Cat
- Join date:
- December 2016
- Posts:
- 270
- Downloads:
- 24
- Uploads:
- 69
- Thanks:
- 58
- Thanked:
- 53 times in 50 posts
October 31, 2017 at 1:43 am #1071116Thought this tweak can help you. Open file
/components/com_jamegafilter/assets/js/megafilter.js
Find this line
self.sort = function (field, dir) {
Try to replace all code of scope starts from the line up above with this one
if (field !== undefined) { self.setQS('sort', field); self.sortField = field; } if (dir == 'asc' || dir == 'desc') { self.setQS('sortdir', dir); self.sortDir = dir; } var d = self.sortDir == 'desc' ? -1 : 1; if (!self.ids.length || (self.sortField == 'position' && d == -1)) self.ids = Object.keys(self.items); // do sort if (self.sortField != 'position') { self.ids.sort(function (a, b) { var v1 = self.getItem(a).getField(self.sortField), v2 = self.getItem(b).getField(self.sortField); // transfer array to string if (Array.isArray(v1)) { v1.sort(); v1 = v1.join(' '); } if (Array.isArray(v2)) { v2.sort(); v2 = v2.join(' '); } if (v1 == v2) { var t1 = +self.getItem(a).getField('id'), t2 = +self.getItem(b).getField('id'); return t1 > t2 ? d : -d; } if ( !isNaN(v1) && !isNaN(v2) ) { v1 = +v1; v2 = +v2; } else if( v1 && v2 ) { v1 = v1.split(''); v2 = v2.split(''); var min = Math.min(v1.length, v2.length); for (var i = 0; i < min; i++) { if (v1 != v2) { return v1.localeCompare(v2) > 0 ? d : -d; } } } return v1 > v2 ? d : -d; }); } else if (d == 1) { self.ids.reverse(); } return self;
Regards
Wisdom is not a product of schooling but of the lifelong attempt to acquire it.
1 user says Thank You to Mr.Cat for this useful post
thesdhotel Friendthesdhotel
- Join date:
- March 2017
- Posts:
- 90
- Downloads:
- 25
- Uploads:
- 1
- Thanks:
- 31
- Thanked:
- 22 times in 20 posts
October 31, 2017 at 1:48 pm #1071368Yep, that fixed the issue for decimal numbers too! Can you include this fix officially in the next update?
EDIT: Wait, this change breaks sorting for alphabetic values. Now numeric values sorting works correctly but alphabetic value sorting doesn’t work anymore.
- This reply was modified 7 years ago by thesdhotel.
- This reply was modified 7 years ago by thesdhotel.
Mr.Cat ModeratorMr.Cat
- Join date:
- December 2016
- Posts:
- 270
- Downloads:
- 24
- Uploads:
- 69
- Thanks:
- 58
- Thanked:
- 53 times in 50 posts
November 1, 2017 at 1:12 am #1071454Could you provide the link for me for further checking?
This code is in the newest version, and the alphabet is working fine on my end.
Regards
Wisdom is not a product of schooling but of the lifelong attempt to acquire it.
thesdhotel Friendthesdhotel
- Join date:
- March 2017
- Posts:
- 90
- Downloads:
- 25
- Uploads:
- 1
- Thanks:
- 31
- Thanked:
- 22 times in 20 posts
November 1, 2017 at 8:16 am #1071547Just try to put this code in the 1.09 Megafilter version and you will see the problem.
But if you say it works in the newest version you’re working on, then maybe it’s because you did some other changes that make it work in the new version. Would you like to send me a private download to the new version so I can test it and report if there are any problems with it before you release it publicly?
- This reply was modified 7 years ago by thesdhotel.
Mr.Cat ModeratorMr.Cat
- Join date:
- December 2016
- Posts:
- 270
- Downloads:
- 24
- Uploads:
- 69
- Thanks:
- 58
- Thanked:
- 53 times in 50 posts
November 1, 2017 at 10:01 am #1071584This reply has been marked as private.Wisdom is not a product of schooling but of the lifelong attempt to acquire it.
1 user says Thank You to Mr.Cat for this useful post
thesdhotel Friendthesdhotel
- Join date:
- March 2017
- Posts:
- 90
- Downloads:
- 25
- Uploads:
- 1
- Thanks:
- 31
- Thanked:
- 22 times in 20 posts
November 1, 2017 at 1:31 pm #1071622WOW, FANTASTIC JOB! I love it!
I tested this thoroughly and everything works perfectly!
- The ordering works indeed correctly with the new update, both for numbers and alphabet. Even decimal order works perfectly.
- I love the fix of empty values going at the bottom as per the other topic.
- Also great job with how you can now use a field to sort without having to also use it as filter
- The loading bar looks nice!
- I see that you have added the cron job feature, great! I haven’t tested this, but I’m sure it will be very useful for your members.
The only issue that I found
I noticed that you added the option to Customize the Layout and choose what to display, great idea! The only problem that I found in the version that you sent me, is that the language strings when editing the layout don’t display correctly. They show as "COM_MEGAFILTER_DEACTIVE_LIST", "COM_MEGAFILTER_SHOW_TITLE" instead of the actual language words for some reason. That is the only issue that I found.
Two final possible additions
I have a couple of ideas for 2 final possible additions, they shouldn’t be too hard, and maybe you can do them for this release:
* Ability to Show/Hide "Position" from the Select Input in the sorting options in Megafilter.
I personally don’t want/need "Position" as a sorting option so I would like to disable it, so far I’ve been doing it manually by commenting it out in "default/view.html.php", but maybe if you added a Show/Hide option it would be perfect, so people don’t have to override the code.* Could you add support for the new "Articles" Field by Regular Labs?(https://www.regularlabs.com/extensions/articlesfield)
This is a super useful extension that adds a Custom Field where you can select from a List of Articles (to connect articles to another article). Essentially what this does, it stores in the "value" field the ID of the selected articles, and then in the frontend it displays the Title of the selected articles.Of course right now, if I try to show this field in Megafilter filters, it simply shows the ID of the article as a frontend_value (which is the default case)
It should be simple to add support for this. The only thing you would have to do is, in the helper.php of content, add a case ‘articles’ : (similar to what you have with case ‘list’ :, the behavior is the same) and in that case, simply retrieve the Title of the Article from the ID (the value is the ID) and display the title of the Article as the frontend_value. (Keep in mind that this field works the same as "List" case, so multiple values are possible)
Thank you so much again for your fantastic work!
- This reply was modified 7 years ago by thesdhotel.
- This reply was modified 7 years ago by thesdhotel.
1 user says Thank You to thesdhotel for this useful post
Mr.Cat ModeratorMr.Cat
- Join date:
- December 2016
- Posts:
- 270
- Downloads:
- 24
- Uploads:
- 69
- Thanks:
- 58
- Thanked:
- 53 times in 50 posts
November 2, 2017 at 10:30 am #1071877About ‘position’ option, if users don’t feel comfortable about it, we’ll consider removing.
For the "Articles" Field, if there are more people interested in, we’ll implement it.
Btw, thanks for your love <3
Wisdom is not a product of schooling but of the lifelong attempt to acquire it.
thesdhotel Friendthesdhotel
- Join date:
- March 2017
- Posts:
- 90
- Downloads:
- 25
- Uploads:
- 1
- Thanks:
- 31
- Thanked:
- 22 times in 20 posts
November 3, 2017 at 11:08 am #1072133Issue with the update:
After upading the Content Plugin, Joomla doesn’t recognize that the Update was made and still says that an Update is available when you go to Manage Extension (Joomla thinks the update was not made).AuthorPostsThis topic contains 16 replies, has 4 voices, and was last updated by thesdhotel 7 years ago.
We moved to new unified forum. Please post all new support queries in our New Forum
Jump to forum