Jump to content

A tip to use Lazy Cron + Import Pages from CSV


Manol
 Share

Recommended Posts

Hello.

      Has anybody used those two modules together?.

      I wish to import a csv file every lets say 24 hours, I would like to use Lazy Cron to do the task, but how can I tell Lazy Cron:

  • to upload the csv file located in the assets folder
  • to use certain template
  • to indicate the parent page
  • to modify the existing pages

Thank you in advance for your help.

Link to comment
Share on other sites

I don't think you can use these two modules together because the ImportPagesCSV module is purely an interactive module used from the admin. It doesn't have an API that you can code around. Nor does it need it, because the module is simply a front-end to ProcessWire's API in terms of importing pages. So to achieve what you are asking (automated background importing) LazyCron will be a fine way to go (and regular Cron even better), but you will handle the import of the CSV yourself rather than using the ImportPagesCSV module. Though you might find it handy to look at the code in ImportPagesCSV to see how to import a CSV file... it's actually very simple, and done with the fgetcsv() function native to PHP. Everything else will just be typical, easy API usage of ProcessWire to create or update pages. Take a look at the while() loop in the first post of this thread, and pretend that it were looping through the results of fgetcsv() rather than a database row. The implementation would be essentially identical. 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...