 | |  |
 |

dhorne
User
Feb 15, 2003, 6:25 AM
Post #1 of 3
(2422 views)
Shortcut
|
|
Database API Questions
|
Can't Post
|
|
I’m moving a site from standard handcoded flatfiles to Article Manager. I’d like to automate this, and am looking to use the Database API. I can parse out the following information from the original site: *Article Title *Author *Subject *Article body *Image filenames I have added a custom field to Article Manager to store the original filename so that I can match the article to the file if required. From looking at the examples that come with the API zip I think I understand what is required to load the files, except where images and custom fields are involved. My questions are as follows: 1. How do I specify the image filenames when I call the API? 2. Do I put ***imagen*** placeholders for the graphics? 3. How do I specify the custom field (original filename)? 4. Do I copy the images to the upload directory? If so I take it that the names will be recognized and the placeholders will be substituted with the appropiate <img> tag when the article is published I’m guessing something like my %rec = ( 'mon' => $mon, 'day' => $day, 'year' => $year, ‘hour’ => hour, ‘min’ => $min, 'name' => $article, 'summary' => $summary, 'content' => $body, 'summary_format' => 'auto', 'content_format' => 'auto', 'status' => 2, 'cat' => 1, 'art_type' => 1, ‘spare1’ => $author, # Is the author the first spare field? ‘spare2’ => $original_name, ‘ufile_image1’ => $image[0], ‘ufile_image2’ => $image[1], ); my $new = &DB_Add($db{'art'}, \%rec); I’m not clear on the relationship between the ufile_image and imagename. Any advice appreciated. Thanks, Dan Dan Horne Redbone Systems Ltd http://www.redbone.co.nz
|
|
|  |
 |

dlo_itools
Staff

Feb 17, 2003, 11:05 AM
Post #2 of 3
(2390 views)
Shortcut
|
|
Re: [dhorne] Database API Questions
[In reply to]
|
Can't Post
|
|
Hi Dan, You're got most of the pieces correct. Here are some answers to your questions: 1. How do I specify the image filenames when I call the API? You do not need to create a separate field for the filename, because that's what the ufile_image fields are for. Each image has three associated fields: ufile_imageN : this is the filename of image imagenameN : this is the internal name for the image; you'll see this in the table of images at the bottom of the Edit Article page captionN : this is the caption displayed under the image when you insert ***imageN*** 2. Do I put ***imagen*** placeholders for the graphics? Yes. After putting in values for the imageN fields, just use ***image*** in your article content to refer to that image. 3. How do I specify the custom field (original filename)? To use the custom fields (or spare fields as they are called in Article Manager), just put the value into a spareN field. When you run Article Manager, you'll still need to go to the setup options to enable those fields, set the fieldname and type, etc. 4. Do I copy the images to the upload directory? If so I take it that the names will be recognized and the placeholders will be substituted with the appropiate <img> tag when the article is published. That is correct. Just put the file into the upload/ directory, using the same as the one you used for ufile_imageN. When you publish an article, the ***imageN*** placeholders will be converted into the correct <img> tag. For example, your %rec line for each record might look like
my %rec = ( ...your previous code... 'spare1' = $author, 'ufile_image1' = $filename1, # e.g. 'boty2002.jpg' 'imagename1' = $imagename1, # e.g. 'Book of the Year 2002' 'caption1' = $caption1, # e.g. "Dan's latest books wins big!" 'spare1' = $some_useful_info, ); If you need more information, just ask anytime. And let us know how your site conversion goes! /Dave Lo
|
|
|  |
 | |  |
|