-
MODX Staff
- 10,725 Posts
Try using $modx->documentContent to manipulate the content to be cached.
No, I only used the alternate event "OnLoadWebDocument". And, instead of parsing the documentOutput, I parsed the documentObject[’content’] field.
The difference from the "traditional" approach is that, while the "OnWebPagePrerender" event is invoked after the parsing process, i.e. immediately before sending the HTML output (and thus when the template has been applied, the snippets evaluated etc.), I had to work with the "raw" document object, as it is stored on the DB. The documentObject[’content’] field is just the content field as edited in the Manager.
I think that working on the content field is fine in most cases, but not always (for example if you want to apply a plugin also to TVs, to evaluated snippets and chunks, it is easier to work with the documentOutput... but maybe there is another easy solution that preserves efficiency).
-
MODX Staff
- 10,725 Posts
Just FYI. The $modx->documentObject[’content’] is just the raw content from the db, and modifying this will only affect the output if called before the parser uses it to establish $modx->documentContent. The $modx->documentContent is the content as it is to be cached and used from cache; the documentObject[’content’] is not used after the initial content is loaded from db or cache except by snippets that specifically use documentObject[’content’]. The documentOutput is copied, either as generated from the db or from cache, from documentContent, before final processing and output. The documentOutput is discarded after being rendered to the viewer. So, you might want to be operating on $modx->documentContent, if you want the plugin effects to be cached. But since I don’t exactly what you are doing, kind of hard to say; just thought I’d mention it.
Hi.
I know, this is an old Topic. But i think this is the right place to post my question:
First of all, i’d like to know if the described process is still valid for MODx Version 0.9.6
If yes, i wonder why Plugins that resize Images don’t use this procedure? Images have to be recalculated only when the site is being changed, right?
Another question regarding the Events:
Is there a event that fires upon saving a Page in the Manager? That would be the ideal place to generate dynamically created Images. Or do i overlook something important?
Cheers // banal