Apparent Clean Solution Found
In case anyone follows me in this, I believe that I’ve found a solution right under my nose: the PHx plugin (
http://wiki.modxcms.com/index.php/PHx).
The plugin allows per-field (tag) output modification via definitions in-template, including application of htmlentities(). I looked under the hood, and it’s even taking the site’s character set into account and using it in the htmlentities() call. Beautiful.
For instance, to clean up the pagetitle in the title element portion of a template, all I had to do was change:
<title>[(site_name)] | [*pagetitle*]</title>
to
<title>[(site_name)] | [*pagetitle:htmlent*]</title>
Wayfinder doesn’t support PHx directly, but it can still be done. A pre-PHx row template like:
<li[+wf.id+][+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]" [+wf.attributes+]><span>[+wf.linktext+]</span></a>[+wf.wrapper+]</li>
becomes
<li[+wf.id+][+wf.classes+]><a href="[+wf.link+]" title="[+phx:input=`[+wf.title+]`:htmlent+]" [+wf.attributes+]><span>[+phx:input=`[+wf.linktext+]`:htmlent+]</span></a>[+wf.wrapper+]</li>
I’m going to drive it around a bit on a non-production site to see if there’s a notable performance penalty (page caching
should negate) or other problems, but it looks like an elegant solution to a problem that’s been bugging me quite a bit.