Anchor link fix for MODX Revolution

Here is a simple plugin that fixes links to anchors on the same page when you have a <base href=""/> tag set. The plugin simply inserts the page url before the pound sign (#) for links that start with a pound sign.

Set this plugin to run on the OnWebPagePrerender event. To disable, just add a system setting called basesite.fix_anchors and set its value to False.

Plugin code:
if (!$modx->getOption('basesite.fix_anchors', null, true)) {
$str = $modx->resource->_output;
$base = $modx->makeUrl($modx->resource->get('id'));
$str = str_replace(' href="#', (' href="'.$base.'#'), $str);
$modx->resource->_output = $str;
return '';