Blog Sections Open
Sorting Ditto Listings by Price from a TV Value
A practical way to let visitors sort Ditto product listings by price when the price is stored in a template variable.
Sorting by price looks simple until the price is stored in a TV and the listing is already driven by Ditto. The donor topic tackled exactly that situation by pairing a request-based sort selector with Ditto’s request extender.
Typical pattern
<form action="[~[*id*]~]" class="sortovkaprice">
<select name="ditto_id1_sortDir" onchange="this.form.submit();">
<option value="ASC">Low to high</option>
<option value="DESC">High to low</option>
</select>
</form>
[!Ditto? &tpl=`sortcategtovar` &extenders=`request` &depth=`1`!]
What to watch
- Make sure the TV data is stored in a format that sorts numerically, not lexically.
- Keep the allowed sort values constrained to the directions you actually support.
- Preserve the selected sort state across requests so the UI reflects the active order.
The main idea is straightforward: the price may live in a TV, but the sorting UX should still behave like a first-class catalog feature.
Newer post
Building Dropdown Navigation with DLBuildMenu in DocLister
How to use DLBuildMenu to generate multi-level dropdown navigation with DocLister in Evolution CMS.
Older post
Filtering Ditto Results by Checkbox TV Values
How to use checkbox TVs as filter inputs for Ditto listings in Evolution CMS without breaking the selected values.