Hello EE Community!
I can’t seem to find an easy solution for my client’s EE functionality request. We want to sort entries using the orderby value but also be able to toggle back and forth between asc and desc views.
The entries are formatted in an HTML table grid type format found below:
http://mobywrap.ehclients.com/eustores/index.php
We want to link the header row (custom fields) to be able to sort by that field. If the field is clicked again then it continues to sort by that field but switches to asc from desc and viceversa.
I tried something such as the following as recommended by Marty’s article about Sorting via URL Segments. I can get the URL to sort via the orderby value but I am not sure how to incorporate the ASC and DESC too.
Here is my current code which orders by the customfield:
<table cellspacing="0" class="list">
<tr>
<th><a href="http://{path=/eustores/byCompany/}">Company Name</a></th>
<th>Address 1</th>
<th>Address 2</th>
<th>City</th>
<th>State/Province/Region</th>
<th>Zip/Capital</th>
<th>Country</th>
<th>Telephone</th>
<th>Web</th>
<th>Store Type</th>
<th>Products Offered</th>
</tr>
{if segment_2 == "byCompany"}{exp:weblog:entries weblog="eustores" orderby="title" sort="asc"}{/if}
{exp:weblog:entries weblog="eustores" sort="desc"}
<tr class="{switch="odd|even"}">
<td>{title}</td>
<td>{address1}</td>
<td>{address2}</td>
<td>{city}</td>
<td>{state_province_region}</td>
<td>{zip_capital}</td>
<td>{country}</td>
<td>{telephone}</td>
<td>{url_address}</td>
<td>{storetype}</td>
<td>{products_offered}</td>
</tr>
{/exp:weblog:entries}
</table>Also since I incorporated the URL sorting, the page parses or loads a lot slower than normal. Any help would be greatly appreciated.
- Andy