Thank you, the example made a useful model. This is what I wanted to do:
<?php
include_once('/path/to/assets/components/smartypants.php');
$contentType = $modx->resource->get('contentType');
if ($contentType == 'text/html') {
$output = &$modx->resource->_output;
$output = SmartyPants($output);
}
?>
Now what I don’t understand is why the plugin doesn’t seem to always work, even after clearing the cache and even when it is just
include_once(’/path/to/assets/components/smartypants.php’);
$output = &$modx->resource->_output;
$output = SmartyPants($output);
on some resources, it works, on others, it doesn’t do anything. If I change the template to empty on those where it doesn’t, it does.
I can’t figure out if this is a bug or a feature, but I’m observing behavior I can’t account for.
1) The plugin does not appear to run on pages that are requested for the first time while logged in -- e.g. a new resource.
2) A resource that had loaded while logged in but prior to the existence of the plugin displays the processed output when the plugin is active and the default output when it isn’t.
3) A new resource displays the processed output when logged out, but as soon as I log back in, the output is not processed by SmartyPants, or at least there is no difference between the output when the plugin is enabled and when it is disabled.
4) Flushing the cache and session cache and browser cache does not alter the behavior I’ve just described.
Does that make any sense?