Sort array modifier

  Previous article Next article  

Sorting the output of an array with this simple Smarty modifier. Sometimes has a problem, a very simple solution...
I was grateful inspired by when making this.

Create a file named "modifier.sort_array.php" and add it to the CMS Made Simple /plugins folder

 * Smarty sort_array modifier plugin
 * Type:     modifier
 * Name:     sort_array
 * Purpose:  alphabetize an array

function smarty_modifier_sort_array($array)
    return $array;  

  How to use

You can alphabetize the output in your template like:

{foreach from=$item|sort_array item='bar'}

  Working example

  Comment Form

Click here to open the form


CMS Made Simple - Tutorials, tips and tricks - CMSMS

Sort array modifier

  Article optimized for CMSMS 2.x

  Last tested in: CMSMS 2.2.7
  Last updated: 18-11-2017
  Comments: 2


Ads help me to help you! Thanks!