I've spent most of two days hacking away at this without success (which tells you something about my PHP skills), and hoped maybe somebody could point me in the right direction.
(I need to apologize in advance: I realize that I should really try to put my extra stuff in a separate module and work with the MARC API, but I'm afraid that's beyond my skill at this point, and I've just been trying to get something to work for the first time. I understand aaustin is quite busy at the moment, and that providing support for a hacked version of the MARC module may not be something he has time for.)
In importing .mrc files, I'm finding that, while most everything is working as expected, certain fields just aren't being recognized or imported. Specifically, I'm not getting the 001, 003, 005, 008, or 009 fields that are the beginning of each of the records I'm trying to import. The one that's really of interest to me in this case is 001.
I had thought that this would get handled by the marcbib_fields function in the marcbib module: it looks like it's returning a marc_clean_field for each $field that it encounters (something that's invoked, for example, in a line like $bib->edition = marc_clean_field(marc_value($marc, '250|a'));). I ended up hacking the module some and used this pattern to treat publication city and publisher information separately (they were imploded at line 33), and that worked just fine. Of the fields that aren't explicitly included in functions like marcbib_author_fields() and so on, 035 and 040 get imported correctly—I assume they're being brought in by the marcbib_fields function. I'm not sure why the 001 field isn't being recognized in the same way, but it isn't.
I've hacked the module to add the following line: $bib->estc_num = marc_clean_field(marc_value($marc, '001'));, which is modeled on other lines around there. I also hacked the marcbib.install file to add a field to my database to receive that value. What I'm seeing, though, is that only the first character of a seven-character code is getting pulled in—so it's getting something, but not the full value (though the MARC directory advertises the 001 field as 7 characters long).
I'm totally in the dark here, so rather than adding more information that might or might not be relevant, I'll just ask if anybody has any tips they might share. Thanks very much for any help.
Comments
Comment #1
benjamin.pauley commented[Updated the title to be more specific: it's only control fields that aren't being brought in. Also shifted from "Documentation" to "Code," since I think this must be a coding issue, rather than something that would be cleared up through documentation.]
Comment #2
aaustin commentedHopefully this is the same as http://drupal.org/node/917450 I overlooked the need to pull in control fields in the marc_value() function.
And this is also another reminder that I need to get customizable fields going.
If things calm down tomorrow, I would really like to help you out on this.
Comment #3
benjamin.pauley commentedThanks so much for working on this. As you can tell, I'm no coder. But I can follow directions, so if there's anything I can do to help the process along, please let me know.
Comment #4
benjamin.pauley commentedI've made some progress on this, but am not all the way there yet. I adapted Dan_Scott's code from http://drupal.org/node/917450#comment-3475782 as follows:
I'm not sure if that's what you meant about pulling in control fields in the marc_value function. That is enough to get the 001 field that I defined as a variable in my hacked marcbib.module to be saved in the field I created in the database, and to get pulled in for the CCK field I had mapped it to.
The 001 field isn't showing up, however, in the MARC tab for the newly-created node (I had added the 001 field in the marc.pages.inc file so that a line always appeared for 001 in the MARC view, but I clearly haven't figured out the whole puzzle, since the value that's now getting pulled in isn't displaying where I thought it was going to). I also don't know what's happening to the other control fields at this point: the .mrc files I'm working with do have 003, 005, 008, and 009 fields, but I don't know where those values are going—or if there's anything set up to receive them yet.
If this is movement in the right direction, I'm happy to put together a patch—or if it's movement in the wrong direction, I'm happy to try to get going on the right track, instead.
Comment #5
aaustin commentedThe reason the 001 field is not showing up in the MaRC view appears to be an oversight. I only really needed the 007 and 008 field so I neglected the other control fields.
The marc_view_record needs to be fixed.
I just tested this code and it appears to work, I just need to commit it: