-
- 3 Posts
One of my clients wants to be able to add posts to their Ditto blog (on a version 0.9.6.3 install) by sending an email to a designated address. I’ve written a class that enables this by checking a specified account and processing the messages with php’s imap functions and then inserting the content from each message as a new record in the site content table. This all works fine, the new documents show up in the manager document tree, but the documents don’t appear Ditto listings until we manually refresh the site cache. (It makes no difference whether the snippet calls are cached or uncached or on a cached or uncached page.)
I think this is because I can’t run the sync cache processor from within my script. My first question is whether this is in fact the cause of the problem.
I haven’t been able to see a way of triggering a cache sync from outside modx. Would it be possible to instantiate a new DocumentParser in my script and trigger the cache sync that way? I’ve cursorily tried modifying some of the code from /manager/index.php to do this, but ran into some initial problems (no errors, but the script exits once the document parser class is included), and didn’t want to pursue it further till I knew it was even possible or advisable.
Any other suggestions?
Thanks a lot,
Aaron
I didn’t get into it all that much; it was just an interesting idea that I thought could be improved on if somebody liked the idea.
I would be inclined to use a modified save_content.processor.php file. You would need to modify where the data comes from (instead of POST values).
It would be much the same as an AJAX application
http://wiki.modxcms.com/index.php/Use_AJAX_with_modxAPI
If you make it a snippet in a document, you’ll have the $modx object and all of its object functions available. If it’s a stand-alone .php file, then you’ll need to include the config.inc.php file and the document.parser.class.inc.php file.
-
- 4,205 Posts
Cool solution...how did you like the CakeMODx API? Did you only need the Cake class without having to load up the MODx engine?