Textpattern CMS support forum
- From: Ukiah, California
- Registered: 2010-06-12
- Posts: 585
Posting articles via back-end PHP script?
Hi all, hope you are doing OK in these pandemonious times!
I have some third-party data sources I’d like to collect and add to my site via a back-end cron job. First, would this work? Second, I have some questions:
- Collect latest RSS from provided sources <— OK so far
- Add formatting <— No idea what will be needed for best interoperation with TXP
- Do I need to format this into textile? How will formatting work for the article body?
- Insert into DB <— recommendations for best practices appreciated!
- Set publish date to 2 days from now
- Send me an email with the edit link to review
Thanks for any input, all assistance is appreciated.
Edit: Just to clarify, I know I can add XML feeds into my site via plugins, but this is more like intentionally posting articles that are collections of data, with additional editing and customization added in.
Last edited by maruchan (2020-05-24 02:00:06)
- From: People's Republic of Cornwall
- Registered: 2005-11-19
- Posts: 2,983
Re: Posting articles via back-end PHP script?
This sounds fun! High level – untested, and this is what I would do, so season to taste:
xsltprocor similar to chew through each XML content block, spit out HTML, tweak formatting until you’re happy with how it looks
pandocor similar to convert from HTML into escaped SQL-friendly title + article files
- use some shell magic to wrap the SQL-friendly files above into a single .sql file with some
NOW() + INTERVAL 2 DAYmagic in the timestamp field, dump into a holding directory
- set a cron task to process any .sql files in said holding directory at a given schedule
I’m running with scissors with some of the above, having not done it before, but it might be of some use.