TinyMCE Rich Text Editor - Anchors - What am I missing?

There exists an anchor plugin from the old forums which should run on OnWebPagePrerender

The code can be improved a bit to:

if ($modx->resource->get('id') != $modx->config['site_start']) {
   $modx->resource->_output = preg_replace('/(href=(\'|"))(#.*?\2)/', '$1' . $modx->makeUrl($modx->resource->get('id'), "", "", "full") . '$3', $modx->resource->_output);
}

Maybe the trailing slash in the forum code is necessary and has to be stripped away. Then there has to be a rtrim added around the makeUrl: rtrim($modx->makeUrl($modx->resource->get('id'), "", "", "full"), '/')

1 Like