Hi all,
I'm developing a module, and I'm fairly uncertain on where to start. I've read the tutorial and such, and it gave me a good overview, but it hasn't answered a lot of my questions.
Here's what I'd like to do:
When a user uploads photos, they'll have the option to upload a tab-delimited text file that was created by Extensis Portfolio. I need to parse this text file to get the keywords out, which won't be a problem. What I'd like to know is where the keywords need to go in the database, and how to access it.
If anyone can help me out, or point me to a tutorial/resource, I'd really appreciate it.
Posts: 8601
take a look at modules/watermark and modules/reupload for some sample code.. you can reuse much of this.
1) your module.inc should have a performFactoryRegistrations function with a registration call like the 3rd one in watermark/module.inc, for the ItemAddOption.
2) copy watermark/WatermarkOption.inc to your own module and modify this ItemAddOption as needed.
- loadTemplate can be much like the code in modules/reupload/ReuploadPhotoOption.inc .. this one is an ItemEditOption, not an ItemAddOption, but it deals with uploading a file.
- make your handleRequestAfterAdd find the uploaded file and parse the contents
- once you have the keywords, lock the item, setKeywords, save and unlock.. see modules/exif/ExifDescriptionOption.inc
3) make a file in templates/ dir to show the file selector, like repload module does
note that performFactoryRegistrations is only called on module activate, so deactivate/reactivate to make your ItemAddOption active.
hope this helps..
Posts: 3
I'm so close to having it done, I just have one problem though...
In the template, I have a file uploader:
And in the code, I can get the file name out, thusly:
However, it doesn't contain the path. For example, it says "file.txt", rather than "C:\misc\file.txt". How can I upload the text file? I don't need it to be added to the database, just use once, then throw away.
Any suggestions/helpful hints?
Posts: 8601
should be $form['tmp_name']['keywords']