Apologies for not being clear. A site designer would call the function from within any smarty template by using the
sortby smarty modifier as applied to the
foreach statement. Generally, it's used within a module template for something like this as I can't see it really being used in the your theme, but it could if you wanted to.
The ExampleLet's say you have a list of submitted entries to display, and the $entries array is composed of $entry arrays where each $entry is composed of the variables age (number), lastName, firstName), but the array is passed to the module template in submission order. When you display it, you would normally use this code:
<{foreach from=$entries item=entry key=entry_id}>
// display each item entry here
<{/foreach}>
But, what if you wanted to sort that array in order by age (oldest first), then Last Name, then First Name (and the module doesn't allow you to select this)? Then you need this solution to do it "on-the-fly" in the templates.
After creating the smarty
sortby modifier function that allows this to work (as described in the previous post), modify the template's
foreach statement in your template to be similar to the following code:
<{foreach from=$entries|sortby"-#age,lastName,firstName" item=entry key=entry_id}>
// display each item entry here
<{/foreach}>
where $entries is the array of $entry which is an array with attributes age, lastName, firstName.
Does that make it clear as mud?