Skip to content

Instantly share code, notes, and snippets.

@crystaldaking
Created November 28, 2019 12:23
Show Gist options
  • Save crystaldaking/cfec7a8762ef87ca8af01fe12308fb53 to your computer and use it in GitHub Desktop.
Save crystaldaking/cfec7a8762ef87ca8af01fe12308fb53 to your computer and use it in GitHub Desktop.
<?php
if (empty($parent) || empty($tplOuter)){
$parent = $modx->resource->get('id');
$tplOuter = 1;
}
$letters = $modx->runSnippet('pdoResources', [
'parent' => $parent,
'tpl' => '@INLINE [[+$pagetitle:first]]',
'sortby' => '{"pagetitle":"ASC"}',
'limit' => 0,
'outputSeparator' => '|'
]);
$arr = explode('|', $letters);
$letterArr = array_unique($arr);
foreach ($letterArr as $char){
$list = $modx->runSnippet('pdoResources', [
'parent' => $parent,
'where' => '{"pagetitle:"ASC"}',
'limit' => 0
]);
$out .= $modx->getChunk($tplOuter, [
'char' => $char,
'items' => $list
]);
}
return $out;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment