This has been baffling me.
The FixedPre plugin just entifies MODX and HTML tags inside <fixedpre></fixedpre>
tags.
In MODX 3, a resource with just this line:
<fixedpre><fixedpre></fixedpre>
displays
<fixedpre>
as it should. In MODX 2, it displays nothing, but both these lines work as they should:
<p><fixedpre><fixedpre></fixedpre></p>
<pre>
<fixedpre><fixedpre></fixedpre>
</pre>
This also works fine:
<p></p>
<fixedpre><fixedpre></fixedpre>
As does this:
<h3></h3>
<fixedpre><fixedpre></fixedpre>
The FixedPre plugin is attached only to OnParseDocument. It’s really simple. Here’s the entire plugin:
if (! function_exists('quote_meta') ) {
function quote_meta($a) {
$lhs = array("<", ">", "[", "]", "!", "{", "}", "`", "*", "~");
$rhs = array("<", ">", "[", "]", "!", "{", "}", "`", "*", "~");
$b = str_replace("&", "\255", $a[2]); //save "&"
$lhs_preg = array('|<!(!*)fixedpre>|', '|<!(!*)/fixedpre>|');
$rhs_preg = array('<$1fixedpre>', '<$1/fixedpre>');
$b = preg_replace($lhs_preg, $rhs_preg, $b);
$b = str_replace($lhs, $rhs, $b);
/* restore '&' as '&' and wrap in span tag */
//return '<span class="fxp">' . str_replace("\255", "&", $b) . '</span>';
return str_replace("\255", "&", $b);
}
}
/** @var $modx modX */
$output =& $modx->documentOutput;
$output = preg_replace_callback("#(<fixedpre>)(.*?)(</fixedpre>)#s",
"quote_meta", $output);
return '';
So in MODX 2 (but not MODX 3), the plugin has to encounter an HTML tag before processing the FixedPre section correctly. HTML in the template that displays the pagetitle doesn’t make it work. The HTML has to be in the page content. Both sites are using the default template from the installation. It also fails with a minimal template in MODX 2.
It’s not a serious problem, because it’s pretty much guaranteed that there will be some HTML tag ahead of the FixedPre section, but it’s bothering me that I can’t figure it out.