ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Sorting Entries Using Orderby via Anchor Text Links

June 02, 2010 12:26pm

Subscribe [2]
  • #1 / Jun 02, 2010 12:26pm

    igrandfunk

    13 posts

    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

  • #2 / Jun 03, 2010 9:01am

    Herb

    224 posts

  • #3 / Jun 03, 2010 12:45pm

    igrandfunk

    13 posts

    Thanks Herb for your reply. However, Dynamic Parameters require POST data from fields right? I am trying to change the preference of the data via anchor text links. I think I might abandon the URL segments though, its really slowing down the parsing.

    - Andy

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases