This is a very nice snippet that outputs an A to Z list of resources. The benefit over SiteAtoZ is the use of templates for output and less html/css coded into the php.
The problem with the snippet is they hard coded the page name in the php. I would like to explore making the snippet usable on any modx resource. Here is the section of the code that needs to be changed:
foreach ($alphaGroups as $alpha => $alphaGroup) {
if (count($alphaGroup) == 0) {
array_push($alphaIndex, $alpha);
} else {
array_push($alphaIndex, '<a href="a-to-z-list.html#' . $alpha . '">' . $alpha . '</a>');
$formattedGroup = '';
$formattedGroup .= '<h3 id="' . $alpha . '">' . $alpha . '</h3>';
foreach ($alphaGroup as $item) {
$formattedGroup .= $pdo->getChunk($itemTpl, $item);
// uncomment the following line to see the item printed out in json format
//$formattedGroup .= json_encode($item, JSON_PRETTY_PRINT);
}
$output .= '<hr>' . $formattedGroup;
}
}
This is the line that needs editing:
array_push($alphaIndex, '<a href="a-to-z-list.html#' . $alpha . '">' . $alpha . '</a>');
I used
array_push($alphaIndex, '<a href="[[~[[*id]] ]]#' . $alpha . '">' . $alpha . '</a>');
Anybody have suggestions to change the this code and improve the code. Is there a better replacement for the link template tag.
Thanks
Roy