Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-05-24 01:46:57

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 585
Website

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)

Offline

#2 2020-05-24 20:22:39

gaekwad
Admin
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:

  • use xsltproc or similar to chew through each XML content block, spit out HTML, tweak formatting until you’re happy with how it looks
  • use pandoc or 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 DAY magic 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.

Offline

#3 2020-05-26 17:04:07

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 585
Website

Re: Posting articles via back-end PHP script?

Thank you gaekwad, I appreciate those ideas. Seems like I have a lot of testing ahead of me. I’ll try to report back on how it goes.

Offline

Board footer

Powered by FluxBB