clearbold / craftimport

It's just starter code; Get in touch if you need help with an import from EE, WordPress, etc. Craft Import is available as a starting point for your own work, with XML & ExpressionEngine template examples. Need help? Get in touch at clearbold.com to book an import to your database from WordPress or EE.
57 stars 3 forks source link

mapping fields to nodes #5

Closed 1stevengrant closed 3 years ago

1stevengrant commented 10 years ago

Mark, Most likely I'm being a tool and not understanding what's going on in CraftImportService.php

However, I have a WP feed at www.harvestglasgow.org/sermon-browser/?podcast and I'm not sure I'm understanding how exactly I should be mapping xml nodes to Craft fields.

Particularly how I'd grab the enclosure URL too.

Any advice?

Best. Steven

heymarkreeves commented 10 years ago

Hi, Steven!

I'd want to point out first that this is really just starter code, as there were no examples of how "just write a quick add-on to import content" at the time :)

If you look at:

https://github.com/clearbold/craftimport/blob/master/eecms-export-template.html

You'll see the XML structure I created. The CraftImportService code is expecting that.

foreach ($xml->blog[0]->entry as $importEntry) {

Says for each entry node in the XML, that is child of blog node, iterate with a reference to that XML node as $importEntry. From there, things like $importEntry->slug are able to fetch child nodes of the current entry node.

So you'd need to rework the CraftImportService code to match your XML or update your XML feed to match the Craft code.

Mark

heymarkreeves commented 10 years ago

Hi, @stevieg83! Were you able to get things working for your setup?

1stevengrant commented 10 years ago

Started looking at this again with Craft projects on the horizon. Assume it's changed somewhat with the new db schema?

heymarkreeves commented 10 years ago

Hi, @stevieg83! I'm not sure. I'd suggest setting up a quick dev site, doing a mysqldump for a backup, and giving it a shot. If anything doesn't match up or fails, I'd love to hear it.

Thanks!

1stevengrant commented 10 years ago

Thanks man. Yeah I managed to get it sorted. It looks like the tag setup piece has changed. I don't need that right now but would certainly be useful in the future. More pressing issue is importing an image path from EE into a Craft Asset field.

Advice I was given was to avoid touching the db directly and just interact with the API.

Not gonna lie, I danced a little when the initial import worked :)

heymarkreeves commented 10 years ago

Great! I think I included some inline comments on where I looked up the API options. That's definitely the way to go. They've provided robust support there to do a lot of the database dirty work.

Feel free to fork and submit a pull request if you make any changes.

Thanks!