OK, I have managed to get something up and running using Template Variables.
<?php
$output = $modx->documentOutput;
$rStart = strpos($output, '<!-- Keyword Replacement Start -->');
$rStop = strpos($output, '<!-- Keyword Replacement End -->');
$rLength = $rStop - $rStart;
if (($rStop !== false) && ($rStart !== false))
{
if (!function_exists('str_replace_once')) {
function str_replace_once($needle , $replace , $haystack){
// Looks for the first occurence of $needle in $haystack
// and replaces it with $replace.
$pos = strpos($haystack, $needle);
if ($pos === false) {
// Nothing found
return $haystack;
}
return substr_replace($haystack, $replace, $pos, strlen($needle));
}
}
$subStr = substr($output, $rStart, $rLength);
$rSubStr = $subStr ;
//$keywords = "machinery safety|machinery-safety.html,European Directive|european-directives.html,CE Marking|ce-marking.html"; // move whats in the speech marks to a template variable called relinklist
$keywords = $modx->getTemplateVarOutput(array("relinklist"));
$array = explode(",", $keywords['relinklist'] );
foreach ($array as &$value) {
$myValues = explode("|", $value);
$replacementText = ' <a href="'.$myValues[1].'">'.$myValues[0].'</a> ';
if (strpos($rSubStr, $replacementText ) === false)
$rSubStr = str_replace_once(' '.$myValues[0].' ', $replacementText, $rSubStr);
}
$modx->documentOutput = str_replace($subStr, $rSubStr, $output);
}
?>
Basically create a template variable called "relinklist" (no quotes) and link it to the template you use.
Then on every page under the Template Variables tab you will see this listed as a field put your keywords in this in the format of "word1|link1,word2|link2" similar to before and save it.
This allows for page individual keywords.