Webmastersite.net
Register Log In

Sorting custom fields

Comments on Sorting custom fields

bimmerbud
Beginner

Usergroup: Customer
Joined: Aug 23, 2013

Total Topics: 1
Total Comments: 2
Sorting custom fields
Posted Aug 23, 2013 - 1:46 PM:

I am going crazy trying to figure out how to sort some custom fields without having them stick after the user leaves the page and goes to a different page. I have a field that has three possible values that I want to sort by. Below is what I currently have, but it is sticking after the user goes back to the main website or anywhere else:

<IF {SWITCH_SORTLINKS} and {CATLINKSHERE}>
<form action="index.php">
<input type="hidden" name="filter" value="TYPE95D32" />
<input type="hidden" name="action" value="displaycat" />
<input type="hidden" name="catid" value="{CATID}" />
<input type="hidden" name="linkfilteraction" value="add" />
Show
<select name="perpage">
<option value="{PERPAGE}">{PERPAGE}</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
<option value="50">50</option>
</select>
listings, ordered by
<select name="filtervalue">
<option value=", Cars By Owner, ">Cars By Owner</option>
<option value=", Cars By Dealer, ">Cars By Dealer</option>
<option value=", Parts For Sale, ">Parts For Sale</option>
</select>
<select name="ascdesc">
<option value="ASC">ascending</option>
<option value="DESC">descending</option>
</select>
<button type="submit" class="gobutton"><img src="{IMAGESURL}/sort.png" alt="" /> Sort</button>
</form>
</IF>
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Aug 23, 2013 - 5:09 PM:

These are filters, not sorts. Unlike sorts, filters are sticky by default but there's an option for non-sticky filters at the bottom of scripts.webmastersite.net/w...ual/other/filters-201.html

If I'm reading my article right, to change your filters from sticky to non-sticky you'll want to change
<input type="hidden" name="filter" value="TYPE95D32" />
<input type="hidden" name="action" value="displaycat" />
<input type="hidden" name="catid" value="{CATID}" />
<input type="hidden" name="linkfilteraction" value="add" />

to
<input type="hidden" name="categoryfiltersfields[0]" value="TYPE95D32" />
<input type="hidden" name="categoryfilterstypes[0]" value="LIKE" />
<input type="hidden" name="action" value="displaycat" />
<input type="hidden" name="catid" value="{CATID}" />

and
<select name="filtervalue">

to
<select name="categoryfiltersvalues[0]">


To handle more fields, just increment the 0 index to 1, 2, etc.

Note that your
<select name="ascdesc">
<option value="ASC">ascending</option>
<option value="DESC">descending</option>
</select>
is serving no purpose in your current form because there are no fields being sorted, only filtered. You can add a sort option into the form with your filters if you want though as the example in the knowledge base does.

You should change the "ordered by" text to "filtered to" too so people understand they're filtering the view.
bimmerbud
Beginner

Usergroup: Customer
Joined: Aug 23, 2013

Total Topics: 1
Total Comments: 2
Posted Aug 26, 2013 - 10:52 PM:

Thanks so much Paul! That worked perfectly!
Search thread for
Download thread as
  • 0/5
  • 1
  • 2
  • 3
  • 4
  • 5



Sorry, you don't have permission to post posts. Log in, or register if you haven't yet.