Welcome to Geeklog, Anonymous Friday, April 26 2024 @ 07:13 am EDT

Geeklog Forums

I need to add a field (ugh!!!)


Interested

Anonymous
I\'m trying to hack admin/story.php so that users can easily add captions to their images. If I get the hack finished (a big if, I know...) I will post it here. This is my first hack, the first anything I have really ever done in PHP. I pretty much have the idea of how everything should be done. ALL I need is to add an input field so the user can enter the caption. I need the field to list right across from its image input field. In other words, if you have five image input fields, then a caption field should next to each (five in all). I have actually gotten this far, but I can\'t seem to get the caption values to display transfer to fieldnames. Only the empty fields show. I have the caption field set up in a table. I think I know how the [imageX] stuff works (UNBELIEVABLY SIMPLE AND BRILLIANT STUFF!). All I need is to be able to properly display the caption fields. Someone, please have a heart and just kick start me here. I don\'t ask stuff unless I just can\'t see how to do it alone.
 Quote

Status: offline

Euan

Forum User
Full Member
Registered: 04/22/02
Posts: 292
unfocused
This is a little hard to help with without some code... Possbible problems: 1) you have a simple typo in the names somewhere (of course you\'ve checked this though) 2) you aren\'t setting the right template/haven\'t closed the template 3) simple HTML error? If you post some code you might get more help. HTH
-- Heather Engineering
-- No job too small
 Quote

Interested

Anonymous
You\'re right about posting code. I would have done it, but I think I remember Dirk saying I couldn\'t post code here. Maybe the forum editor gets weird. I\'ll look over the code and in a moment post the snippet that seems to be giving me a problem. Thanks!
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by Interested:I think I remember Dirk saying I couldn\'t post code here. Maybe the forum editor gets weird.
Make sure to enclose it in CODE tags (the one with the square brackets you get when you use the CODE button in the forum editor, not the HTML code tags) and you should be fine. bye, Dirk
 Quote

Interested

Anonymous
// Snippet from /admin/story.php - found near the end of the
// function "storyeditor." I have added a field "ai_caption" to
// the "article_images" table

$fileinputs = '';
$saved_images = '';
if ($_CONF['maximagesperarticle'] > 0) {
$story_templates->set_var('lang_images', $LANG24[47]);
$icount = DB_count($_TABLES['article_images'],'ai_sid', $A['sid']);
if ($icount > 0) {
$result_articles = DB_query("SELECT * FROM {$_TABLES['article_images']} WHERE ai_sid = '{$A['sid']}'&quotWink;
for ($z = 1; $z <= $icount; $z++) {
$I = DB_fetchArray($result_articles);

// Here is where I attached the caption to $saved_images, which is
// displayed in the storyeditor template. This seems to work just fine.
// But I can't seem to save the caption data in the ai_caption field. I also
// don't know how to retrieve the data. It isn't entirely obvious in the
// code.

$saved_images .= $z . 'Wink <a href="' . $_CONF['site_url'] . '/images/articles/' . $I['ai_filename'] . '" target="_blank">' . $I['ai_filename'] . '</a>';
$saved_images .= '   ' . $LANG24[52] . ': <input type="checkbox" name="delete[' .$I['ai_img_num'] . ']">' . $LANG24[58] . ': <input type="text" name="caption" value ="' . $I['ai_caption'] . '"><br>';

}
}

// I am assuming this code will allow the caption data to show up where
// there are "new allowed" article images. I want the captions to be
// editable at all times. So I put an input field here too.

$newallowed = $_CONF['maximagesperarticle'] - $icount;
for ($z = $icount + 1; $z <= $_CONF['maximagesperarticle']; $z++) {
$fileinputs .= $z . 'Wink <input type="file" name="file' . $z . '"> ' . $LANG24[58] . ': <input type="text" name="caption' . $z . '">';
if ($z < $_CONF['maximagesperarticle']) {
$fileinputs .= '<br>';
}
}
$fileinputs .= '<br>' . $LANG24[51] . '<br>';
}
$story_templates->set_var('saved_images', $saved_images);
$story_templates->set_var('image_form_elements', $fileinputs);
...

As I said, this all seems to work just fine. But I REALLY cannot figure out how to save the caption data in the table's ai_caption field. I also don't know how to retrieve the data.

I hope someone can help. I think once I get over this hurdle, I can figure out the rest of the hack.
 Quote

Interested

Anonymous
Yeah. I get a list of caption fields. I can even input the caption, but when I save the story and then check the article_images table, the caption field is not updated with the value I entered. So close and so far.
 Quote

All times are EDT. The time is now 07:13 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content