Override the content of the Page before sending to browser

I want to be able to override, make some changes to the Page context/text before it is shown in the browser to the user.

Example: When editing Page content I want to be able to do the following:

<p>Etiam ac faucibus augue, a imperdiet quam. Curabitur vitae ex auctor, pellentesque risus quis, venenatis nisl. Ut fringilla dui at aliquet lobortis.</p>
<p>Praesent feugiat mi quis odio lobortis, eu luctus lorem tristique. Nam eu molestie orci. Aenean venenatis turpis at sapien congue dictum. Phasellus maximus vel sapien ut vestibulum.</p>

I want to filter out {{custom_tag}}, and add my custom HTML to replace it.

Two potential options:

If you have the view template under your own control then you can move the replacement logic into the browser view for doing the replacement on the fly.

1 Like

No idea if it is a good idea, but you could have two fields and use an event subsciber to save 'changed content from field ' in field 2

The reason for doing that t way would (only) be for keeping the original markup also.

I assume it would also be possible to use a custom widget to render. Again: no idea if it is a stupid idea (but it is probably easier to make than a portal transform ( you could do simple search / replace in the widgets 'def render' (?)

Plone Foundation Code of Conduct