pepebe
7/13/2012 - 4:27 PM

MODX REVO: Sorting a @SELECT-bound and UNION'ed ListBox TV

MODX REVO: Sorting a @SELECT-bound and UNION'ed ListBox TV

/* Source: http://forums.modx.com/index.php?topic=30102.0 

Eequirements for a new Template Variable (TV):

select box
filled with a list of documents from a certain modx container
also wanted @INHERIT to appear at end of select box list
wanted documents sorted according to their menuindex

*/

@SELECT pagetitle, id FROM ( (SELECT pagetitle, id, menuindex FROM [+PREFIX+]site_content WHERE parent = 21) UNION (SELECT '@INHERIT', '@INHERIT', 9999) ORDER BY menuindex) as sc