Here's an extension to the plugin example (in the help docs) that retains any url parameters. I hope it's of use to someone.
<?php
if ( $modx->resource->get('id') !=$modx->config['site_start'] ) {
$params = '';
if (count($_GET) > 1 ){
$arr = $_GET;
array_shift($arr);
$params = '?'. urldecode(http_build_query($arr, "\n"));
}
$url = $modx->makeUrl($modx->resource->get('id')) . $params . '#';
$modx->resource->_output = str_replace('href="#','href="' .$url ,$modx->resource->_output);
unset($arr);
unset($params);
unset($url);
}
https://gist.github.com/Finetuned/840eafd9907008c4b4e3.js
Original:
http://rtfm.modx.com/revolution/2.x/making-sites-with-modx/structuring-your-site/resources/named-anchor