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 issue with dynamic parameters

November 21, 2011 1:53pm

Subscribe [2]
  • #1 / Nov 21, 2011 1:53pm

    PDM

    61 posts

    Hello,

    Was wondering the best way to handle a sorting issue using dynamic_parameters. I have a job listing with options to sort by date posted, date closed, and position title.

    For the “Date Closed” some jobs are set to display an actual date (default expiration_date), while others display “Until Filled” (using custom field). The “Until Filled” jobs have an expiration date defaulted to 3 mos from post date in the admin, but display “Until Filled” on the public view.

    For the sort by Date Closed, I’d like to list the Until Filled jobs at the top or bottom, depending on sort value selected, but obviously right now they’re sorting on their expiration date stored in the back end. Was thinking I could assign a value of “9999999999” to the expiration date in the template when until_filled is selected, but still display “Until Filled” but can’t get it to work.

    Here is the basic code for the page. Any ideas? Thank you!

    <form method="post" action="{path='jobs'}">
    
    <select name="orderby">
    <option value="date">Sort By:</option>
    <option value="date">Date Posted</option>
    <option value="expiration_date">Date Closes</option>
    <option value="title">Position</option>
    </select>
    
    <select name="sort">
    <option value="asc">Order In:</option>
    <option value="asc">Ascending</option>
    <option value="desc">Descending</option>
    </select>
    
    <input type="submit" value="Go!" />
    
    </form>
    
    <table>
    <tr>
     <th>Posted</th>
     <th>Closes</th>
     <th>Position</th>
    </tr>
    
    {exp:channel:entries channel="jobs" dynamic_parameters="orderby|sort" orderby="date" sort="desc"}
    
    <tr>
     <td>{entry_date format="%M %j, %Y"}</td>
     <td>{if until_filled}Until Filled{if:else}{expiration_date format="%M %j, %Y"}{/if}</td>
     <td><a href="/jobs/{url_title}/">{title}</a></td>
    </tr>
    
    {/exp:channel:entries}
    
    </table>
  • #2 / Nov 22, 2011 1:37pm

    Kevin Smith

    4784 posts

    Hi PDM,

    I’m not sure there’s a way to get dynamic parameters to behave that way. If it’s going to sort by a particular field, it needs to assume that all the information in that field is the same kind of data, and there aren’t any expections built into the system.

    I hate that I don’t have a better answer for you, but this might be just the kind of situation that calls for some custom development work.

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

ExpressionEngine News!

#eecms, #events, #releases