Quote from: OpenGeek at May 27, 2011, 12:29 PM
What event is this attached to? That will only work with OnParseDocument in 2.1, but I don’t think that is the correct event for what you are attempting here. I believe you want to use $modx->resource->_output instead of $modx->documentOutput if you are using OnWebPagePrerender. The documentOutput variable probably should have been removed completely for 2.1, but I’m not sure an appropriate replacement has been realized yet.
yes this is for OnWebPagePrerender (which works for 2.1 and my 2.0.8 to 2.1 tests show it working as well)
so would the rewrite be??
<?php
function delete_template_nodes($delete_node,$preserve_node) {
global $modx; // Without this, the $modx var is out of scope.
$delete_node = preg_quote($delete_node);
$pattern = '/\<'.$delete_node.'\>(.*)\<\/'.$delete_node.'\>/Usi';
$modx->resource->_output = preg_replace($pattern,'',$modx->resource->_output);
$preserve_node = preg_quote($preserve_node);
$pattern = '/\<'.$preserve_node.'\>/Usi';
$modx->resource->_output = preg_replace($pattern,'',$modx->resource->_output);
$pattern = '/\<\/'.$preserve_node.'\>/Usi';
$modx->resource->_output = preg_replace($pattern,'',$modx->resource->_output);
}