Node Import from HTML Files
I have a D7 site--it's now live and doing well and the next step is to import a large set of staff bios. They are right now stored as PHP files, in a very organized format. They have these fields: Name Title Bio Image which must be parsed out of the HTML, and for Image, I must actually of course import the image as an image file. It looks like I would NOT have to parse the PHP b/c the PHP part is unrelated to the content items I need. I just need to parse out, for example, in a div with class="title" there is an H2 with his name and a P with the person's title. I think I can an XML parser in PHP to get those items. My first question is, should I be looking into the Feeds module, the Migrate module or do this with custom code? Once I get started hopefully I can finish. :) Thanks, Fred
On Thu, May 3, 2012 at 11:17 AM, Fred Jones <fredthejonester@gmail.com> wrote:
I have a D7 site--it's now live and doing well and the next step is to import a large set of staff bios. They are right now stored as PHP files, in a very organized format. They have these fields:
Name Title Bio Image
which must be parsed out of the HTML, and for Image, I must actually of course import the image as an image file. It looks like I would NOT have to parse the PHP b/c the PHP part is unrelated to the content items I need. I just need to parse out, for example, in a div with class="title" there is an H2 with his name and a P with the person's title.
I think I can an XML parser in PHP to get those items.
My first question is, should I be looking into the Feeds module, the Migrate module or do this with custom code? Once I get started hopefully I can finish. :)
So is this more for individual user profiles or one page giving the staff data to anonymous users? It sounds like more than one page so you could create a staff content type and add fields for data. If all the pages use well formed xhtml using the XML parser might be good but otherwise you need the DOM parser. I think I would custom code it but I don't know what you have exactly. -- Earnie -- https://sites.google.com/site/earnieboyd
So is this more for individual user profiles or one page giving the staff data to anonymous users? It sounds like more than one page so you could create a staff content type and add fields for data. If all the pages use well formed xhtml using the XML parser might be good but otherwise you need the DOM parser. I think I would custom code it but I don't know what you have exactly.
OK I also thought custom code makes the most sense. But now I wonder if these should be Users instead of a staff content type. In D7 they should be extensible as entities I think. I suppose I could use http://drupal.org/project/profile2 or create fields directly on the user entity, but I don't know how to do that. Yet. :) I see this http://drupal.org/node/993934 but I don't have Profile on my site. Nor do I see that it's a core option. Thanks, Fred
Sorry for my late entry. Any time you see the Profile module mentioned concerning D6 and before, automatically translate that to Profile2 in D7. (Big secret: Profile is still there.) Then you might find the Migrate module useful for this. I can't imagine that you are talking about a huge amount of data here. I'd probably create a few manually, look at how the database stores those, and then probably write a quick little module to update the database directly. From what I remember seeing this shouldn't be difficult. Another approach would be to simply use http://api.drupal.org/api/drupal/modules!user!user.module/function/user_save... stick the new fields into the $edit array. Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
________________________________ From: Fred Jones
OK I also thought custom code makes the most sense. But now I wonder if these should be Users instead of a staff content type. In D7 they should be extensible as entities I think. I suppose I could use http://drupal.org/project/profile2 or create fields directly on the user entity, but I don't know how to do that. Yet. :)
I see this http://drupal.org/node/993934 but I don't have Profile on my site. Nor do I see that it's a core option.
Nancy, cool, thanks. That answers it. Yeah, I think user_save() is the best. Now I just must figure out how to import images also, but I'm sure I can find that. Thanks! Fred
participants (3)
-
Earnie Boyd -
Fred Jones -
Ms. Nancy Wichmann