Hello Matt,
thanks you for your reply. That was absolutly that for what iam looking. sometimes i forgot the wiki existent.
But.....
what i want to do is catching all <pre> Tags, replace it with an placeholder and put them back after parsing/merging the content.
The meaning is to protecting them before the parser will destroy all the codesnippets in it.
$e = &$modx->Event;
//var_dump( $e );
$_SESSION['codeblocks'] = array();
$i = 1;
switch ($e->name)
{
case "OnParseDocument":
$content_raw = $modx->documentObject['content'];
// echo $content_raw;
function catchCodeblocks( $codeblocks )
{
global $i;
$replacement = str_replace($codeblocks[0],'#codeblock#-'.$i.'-#',$codeblocks[0]);
$_SESSION['codeblocks'][$replacement] = $codeblocks[0];
$i++;
return $replacement;
}
$content_tmp = preg_replace_callback('|<pre>(.*?)</pre>|si', 'catchCodeblocks', $content_raw);
//echo $content_tmp;
$modx->documentObject['content'] = $content_tmp;
break;
case 'OnWebPagePrerender':
//$o = &$modx->documentOutput;
$content_tmp = $modx->documentObject['content'];
//echo $content_tmp;
function setCodeblocks( $replacements )
{
return str_replace($replacements[0],$_SESSION['codeblocks'][$replacements[0]],$replacements[0]);
}
$content = preg_replace_callback('|#codeblock#-(.*?)-#|si', 'setCodeblocks', $content_tmp);
//echo $content;
$modx->documentObject['content'] = $content;
break;
default :
return;
break;
}
Both events are checked. if i put the code directly in the plugintextarea, absolutly nothing will happen.
if i include it by require_once from the filesystem, i will work... that means, the first part will work, the second part is ignored.
if i splitt it in two plugins and check onParseDocument for the first and onPagePrerender for the second, same result.. onParse work, onPrerender not.
damn.... I dont await your reply.. just writing down my thoughts...
thank you
ciao, Stefan