LiveWhale CMS

Welcome, Guest Login

Support Center

Our documentation is moving:

Please check for the most up-to-date LiveWhale CMS and LiveWhale Calendar documentation. The below legacy documentation will remain available as a reference until the documentation migration is complete.

Adding a custom widget sort method

Last Updated: Jun 20, 2017 10:08AM PDT
While LiveWhale widgets come with a variety of sort method, there are occasions when you’ll need a custom sort method to meet a specific need. To create a custom sort method for a LiveWhale widget, you’ll need SFTP access to your server and a reasonable knowledge of PHP and SQL.
  1. Connect to your server via SFTP and locate your ./livewhale/client/global.config.php in the LiveWhale back-end.
  2. The following code adds a reverse sort for a custom profile field (ex., profiles_102). 
    $_LW->REGISTERED_WIDGETS['profiles']['widget']['sort_fields'] =
     array( 'Custom Field: Year' => 'profiles_102 DESC');
    • Enter the content type (profiles, news, events, forms, galleries, etc): 
      • $_LW->REGISTERED_WIDGETS['content type here']['widget']['sort_fields'].
      • Adding additional sorts to multiple widget types requires a separate statement for each. 
    • Enter the label of the your sort method which will be shown in your widget editor drop-down menu (ex. 'Custom Field: Year') 
    • Enter the field to sort by and the sorting method (Desc, Asc) (ie, 'profiles_102 DESC') is the SQL sort that will be used to order the results.
    • You can list secondary (or tertiary) sorting preferences comma separated after the first as in a typical SQL query SORT BY (e.g., 'profiles_102 DESC, profiles_103' – for built-in fields, use the table name, e.g., 'profiles_102 DESC, livewhale_profiles.title')
  3. Once you’ve added the statement in your configuration file visit your widget editor for the matching widget type to make sure that the sort method appears and works as you intend.


Sorting on a Date string (ex., '10/10/2016') when the field is not a date type. The example below sorts on the year first, then the month, followed by the day. The SQL MID() function is used to extract characters from a text field.

​$_LW->REGISTERED_WIDGETS['profiles']['widget']['sort_fields']=array('Exhibit Order Date' => 'MID(profiles_102,7,4) DESC, MID(profiles_102,1,2) DESC,  MID(profiles_102,4,2) DESC');
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
Invalid characters found