Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Carl Maltby Posted December 9, 2015 Posted December 9, 2015 Hi everyone, This is somewhat of a bothersome thing. The Sort By dropdown in the listing pages has far too many options. The categoryTable template (where this is generated) doesn't seem to hold any immediate answers as to whether the sort options are even filtered. For example, our Tutorials section displays the following Sort By options: Last Reply Title Start Date Most Commented Most Viewed sort_record_last_comment sort_record_comments sort_record_views Title sort_record_publish_date Tutorial Header Image Difficulty Creative Commons Licencing Creative Commons Licencing Attribution Teaser Custom Clearly this looks ridiculous and shoddy to the end user. Do we need to manually specify sort options in the HTML template (categoryTable) or is there a more graceful way of doing this in the ACP? http://www.projectguitar.com/tutorials/instrument-building/ TIA
opentype Posted December 9, 2015 Posted December 9, 2015 There is no way around this currently, but there was a feature request about this months ago. It should just be an option in the field settings, so fields can be turned off for sorting. And in addition it needs a way to deal with ASC or DESC direction either on the admin or user side. For some fields the resulting ordering just doesn’t make any sense.
chilihead Posted December 9, 2015 Posted December 9, 2015 30 minutes ago, Carl Maltby said: sort_record_last_comment sort_record_comments sort_record_views sort_record_publish_date Looks like some missing language too.
Carl Maltby Posted December 9, 2015 Author Posted December 9, 2015 19 minutes ago, opentype said: There is no way to around this currently, but there was a feature request about this months ago. It should just be an option in the field settings, so fields can be turned off for sorting. And in addition it needs a way to deal with ASC or DESC direction either on the admin or user side. For some fields the resulting ordering just doesn’t make any sense. That's exactly what I was expecting somewhere in the ACP also. It shouldn't be too onerous to roll into the software, however I suspect that without any intervention modifying how settings are rendered through the templates, it is "semi-hardcoded" into Pages. I suspect that this bit of HTML Database Template code from will be a continuing bugbear (default, categoryTable): {{if isset( $table->sortOptions ) and !empty( $table->sortOptions )}} <li> <a href="#elSortByMenu_menu" id="elSortByMenu_{$table->uniqueId}" data-role='sortButton' data-ipsMenu data-ipsMenu-activeClass="ipsButtonRow_active" data-ipsMenu-selectable="radio">{lang="sort_by"} <i class="fa fa-caret-down"></i></a> <ul class="ipsMenu ipsMenu_auto ipsMenu_withStem ipsMenu_selectable ipsHide" id="elSortByMenu_{$table->uniqueId}_menu"> {{$custom = TRUE;}} {{foreach $table->sortOptions as $k => $col}} <li class="ipsMenu_item {{if $col === $table->sortBy}}{{$custom = FALSE;}}ipsMenu_itemChecked{{endif}}" data-ipsMenuValue="{$col}" data-sortDirection='{{if $col == 'title'}}asc{{else}}desc{{endif}}'><a href="{$table->baseUrl->setQueryString( array( 'filter' => $table->filter, 'sortby' => $col, 'sortdirection' => ( $col == 'title' ) ? 'asc' : 'desc', 'page' => '1' ) )}">{lang="{$table->langPrefix}sort_{$k}"}</a></li> {{endforeach}} {{if $table->advancedSearch}} <li class="ipsMenu_item {{if $custom}}ipsMenu_itemChecked{{endif}}" data-noSelect="true"> <a href='{$table->baseUrl->setQueryString( array( 'advancedSearchForm' => '1', 'filter' => $table->filter, 'sortby' => $table->sortBy, 'sortdirection' => $table->sortDirection ) )}' data-ipsDialog data-ipsDialog-title='{lang="custom_sort"}'>{lang="custom"}</a> </li> {{endif}} </ul> </li> {{endif}} If needs be, this can simply be hard-coded however that's about as graceful as a brick. ----- 13 minutes ago, chilihead said: Looks like some missing language too. Possibly. I asked a while back about a separate database field ($num_views) since it has been made (from what I am aware) read-only since 3.x; the problem was that we couldn't transfer a record from one database to another and manually set the value of $num_views to reflect view counts from the previous database. I don't normally need to touch language strings, however I suspect that fields like this which are not usually "public facing" don't have language strings associate with them? Nice to see that internal information strings are automagically leaking out.
snugRugBug Posted December 9, 2015 Posted December 9, 2015 A while back I made a workaround for this problem. First, find the template where the filter menu is generated (for me it was Database Templates -> Record Listing -> categoryTable). Add the keys of the fields you want to have filtered to an array like this: {{$allowed_sorts = array();}} {{$allowed_sorts[] = "title";}} {{$allowed_sorts[] = "rating";}} {{$allowed_sorts[] = "field_22";}} I put this right at the top of the template. Then, find this loop in the template: {{foreach $table->sortOptions as $k => $col}} <!-- Some html inserting each menu item --> {{endforeach}} and change it to this: {{foreach $table->sortOptions as $k => $col}} {{if array_search( $k, $allowed_sorts )!==FALSE }} <!-- Some html inserting each menu item --> {{endif}} {{endforeach}} This is not a very pretty solution. If you add a new field later, you'll have to come back to this template and add the field key to the allowed_sorts array. But it will probably work until IPS adds this feature.
Carl Maltby Posted December 9, 2015 Author Posted December 9, 2015 Apologies for the repeated use of the word "suspect". This is mostly reflexive since I'm juggling way too much sand to dedicate all my mental resources this morning.... That's more or less what I suspected would be required, @snugRugBug. I was thinking more of a simple manual list rather than one of exclusion also.
m@t Posted December 9, 2015 Posted December 9, 2015 I have reported this issue - fixed with next release
Action_Builder Posted March 22, 2016 Posted March 22, 2016 Has this issue been fixed in a new release? I have a custom page, database and fields and when I go to sort the page I have at 20 items to choose from. I want to eliminate all the default IPS items like Most Commented, Most Reviewed, Most Viewed, etc. Is there a way to do this in the Admin CP? @snugRugBug thanks for the workaround on this. I appreciate your contributions.
Daniel F Posted March 22, 2016 Posted March 22, 2016 51 minutes ago, Action_Builder said: Has this issue been fixed in a new release? I have a custom page, database and fields and when I go to sort the page I have at 20 items to choose from. I want to eliminate all the default IPS items like Most Commented, Most Reviewed, Most Viewed, etc. Is there a way to do this in the Admin CP? @snugRugBug thanks for the workaround on this. I appreciate your contributions. Yes, this will be resolved with 4.1.9 . We're running here the beta and you can see in our bugtracker that we don't have any duplicate items anymore https://invisionpower.com/4bugtrack/active-reports/
Action_Builder Posted March 24, 2016 Posted March 24, 2016 I have 4.1.9 installed and I think this issue has not been resolved and may have gotten worse. When I click on Sort By I get a long list of ALL my custom fields even those that I have marked as No to "Allow filtering". @Daniel F am I doing something wrong? How is the bug tracker set up?
Daniel F Posted March 24, 2016 Posted March 24, 2016 Please submit a ticket for further investigation
opentype Posted March 24, 2016 Posted March 24, 2016 10 minutes ago, Action_Builder said: … even those that I have marked as No to "Allow filtering". The filter option is for the filter widget. It doesn’t affect the sorting drop down, which can’t be customized currently.
Action_Builder Posted March 24, 2016 Posted March 24, 2016 @opentype are you referring to the types of widgets found here? I don't see anything info about a filter widget. Can you provide a link to the filter widget?
opentype Posted March 24, 2016 Posted March 24, 2016 It’s called Database Filters in the block manager. An example is the filter in the bug tracker here on this site.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.