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>