Hi, I have a Resource List TV, with a limit of 20 - I need this to display the 20 most recent resources, but instead is showing the oldest. Is there a way to specify the sort order/direction?
Thanks,
Rod.
-
☆ A M B ☆
- 24,524 Posts
Not that I know of, someone else may know more about it though.
-
☆ A M B ☆
- 24,524 Posts
Looking at core/model/modx/processors/element/tv/renders/mgr/input/resourcelist.class.php on line 52, you could edit that to be DESC. This would be reverted every time you upgrade MODX, however.
-
☆ A M B ☆
- 24,524 Posts
Actually, it looks like it's sorting by menuindex, not create date.
$c->sortby('Parent.menuindex,modResource.menuindex','DESC');
You might try something like this with an @SELECT TV:
@SELECT `pagetitle`,`id` FROM `modx_site_content` WHERE `parent` = 6 AND `published`= 1 ORDER BY `createdon` ASC
Or a custom snippet:
[[ShowChildren? &parentId=`12`]]
$c = $modx->newQuery('modResource');
$c->sortby('createdon', 'ASC');
$parent = $scriptProperties['parentId'];
$children = $modx->getCollection('modResource', array('parent' => $parentId));
$output = '<ul>';
foreach ($children as $child) {
$output .= "\n<li>" . $child->get('pagetitle') . '</li>';
}
$output .= '</ul>';
return $output;