Jump to content

Batch XML nodes to repeater fields


nuel
 Share

Recommended Posts

hi there

i'm new to processwire, please cut me some slack if the answer is already out there..

i am "processwiring" a non-cms page that i made, containing many repeating so called "station"-elements with fields such as date, location, miles, optional links, photo upload etc. they were listed and created via php and stored in an xml file until now:

<stations>
  <station>
    <date>17.8.2017</date>
    <location>Exil, Zurich</location>
    <miles>1234</miles>
    ...
  </station>
  <station>
    ...
  </station>
</stations>

i already created a working repeater field with the needed fields and successfully created the first two elements... but there are many more!

what is the easiest and quickest way to batch create new repeater fields with the node element content of my xml file?

otherwise i would just have to type the whole sh..t again which i am too damn lazy to do :D

thanks in advance

nuel

Link to comment
Share on other sites

It's easy to import an XML and populate the fields via PW's great API. You can create a module, or a simple script that can run in a template or via command line.

Take a look on the source code of the MarkupLoadRSS module: https://github.com/ryancramerdesign/MarkupLoadRSS/blob/master/MarkupLoadRSS.module

I think you can adapt it to your needs very quickly. :)

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

×
×
  • Create New...