4images Forum & Community

4images Issues / Ausgaben => Feedback & Suggestions => Topic started by: Ofuuzo on April 16, 2002, 06:19:09 PM

Title: Add two fields to the database
Post by: Ofuuzo on April 16, 2002, 06:19:09 PM
Hi,

I want to  add two  fields to the database  to show not only the keywords, description, date ...

Can you point me in which files (or  functions, arguments) to do that?

Thanks in advance.

- Ofuuzo
Title: Add two fields to the database
Post by: Jan on April 17, 2002, 08:57:13 PM
Hi,

hard to explain.

check:

functions.php ->ShowImage()
details.php
admin/images.php

Jan
Title: Add two fields to the database
Post by: Ofuuzo on April 18, 2002, 03:16:13 PM
Thanks.  I have added the fields and I got it working.

- Ofuuzo
Title: Re: Add two fields to the database
Post by: alex2k on April 19, 2002, 09:23:58 AM
Quote from: Ofuuzo
Thanks.  I have added the fields and I got it working.

- Ofuuzo


Can you tell me how to do that, please....
I need to adding some fields too.
Thank's....
Title: Add two fields to the database
Post by: Ofuuzo on April 23, 2002, 02:42:29 PM
Here is an example of what you can do:
Add field(s) , example "image_test"  to the database

/global.php file
//-----------------------------------------------------
//--- Get Image Caches ------
//-----------------------------------------------------
$result = $site_db->query("SELECT image_id, cat_id, user_id, image_name, image_description, image_keywords, image_test, .............

/admin/images: near line 132 and further:
  $image_test = trim($HTTP_POST_VARS['image_test']);

................
  if (empty($error)) {
    @unlink(MEDIA_PATH."/".$cat_id."/".$old_file_name.".bak");
    ....
    $result = $site_db->query("UPDATE ".IMAGES_TABLE."
                               SET cat_id = '$cat_id', image_name = '".htmlspecialchars($image_name)."', image_description = '$image_description', image_keywords = '".htmlspecialchars($image_keywords)."', image_date = $image_date, image_active = '$image_active', image_media_file = '$new_name', image_thumb_file = '$new_thumb_name', image_allow_comments = '$image_allow_comments', image_downloads = '$image_downloads', image_votes = '$image_votes', image_rating = '$image_rating', image_hits = '$image_hits', image_test = '$image_test'
                               WHERE image_id = '$image_id'");
    if ($result) {
      remove_search_words($image_id);
      add_search_words($image_id, stripslashes($image_name), stripslashes($image_description), stripslashes($image_keywords), stripslashes($image_test) );

..............

 maketextareacode($lang['field_keywords_ext'], "image_keywords", $image['image_keywords'], $textarea_size);
  maketextareacode($lang['field_test_ext'], "image_test", $image['image_test'], $textarea_size);
..........

 makeinputcode($lang['field_keywords_contains'], "image_keywords", "", $textinput_size);
  makeinputcode($lang['field_test_contains'], "image_test", "", $textinput_size);
.....
 $image_keywords = trim($HTTP_POST_VARS['image_keywords']);
  if ($image_keywords !== "") {
    $condition .= " AND INSTR(LCASE(image_keywords),'".strtolower(htmlspecialchars($image_keywords))."')>0";
  }
  $image_test = trim($HTTP_POST_VARS['image_test']);
  if ($image_test !== "") {
    $condition .= " AND INSTR(LCASE(image_test),'".strtolower($image_test)."')>0";
  }
--------------
   makehiddencode("image_description", $image_description, 1);
    makehiddencode("image_keywords", $image_keywords, 1);
    makehiddencode("image_test", $image_test, 1);
...............

//Save to Database
      if (!$uploaderror) {
        $image_name = trim($HTTP_POST_VARS['image_name_'.$i]);
        $image_description = unhtmlspecialchars(trim($HTTP_POST_VARS['image_description_'.$i]));
        $image_test = unhtmlspecialchars(trim($HTTP_POST_VARS['image_test_'.$i]));
...............................

 $result = $site_db->query("INSERT INTO ".IMAGES_TABLE."
                                   (cat_id, user_id, image_name, image_description, image_keywords, image_test, image_date, image_active, image_media_file, image_thumb_file, image_allow_comments)
                                   VALUES ('$cat_id', '".$userinfo['user_id']."', '".htmlspecialchars($image_name)."', '$image_description', '".htmlspecialchars($image_keywords)."','$image_test', '".time()."', '$image_active', '$new_name', '$new_thumb_name', '$image_allow_comments')");
        $image_id = $site_db->get_insert_id();
...............

 for ($i = 1; $i <= $num_newimages; $i++) {
    maketableseparator($lang['image']." ".$i, 2);
    makeuploadcode($lang['image'], "file_".$i, "<br /><span class=smalltext>".$lang['allowed_mediatypes_desc'].str_replace(",",", ",$config['allowed_mediatypes'])."</span>");
    makeuploadcode($lang['thumb'], "thumb_file_".$i, "<br /><span class=smalltext>".$lang['allowed_mediatypes_desc']." jpg, gif, png</span>");
    makeinputcode($lang['field_image_name'], "image_name_".$i, "", $textinput_size);
    maketextareacode($lang['field_description_ext'],"image_description_".$i, "", $textarea_size);
    maketextareacode($lang['field_keywords_ext'], "image_keywords_".$i, "", $textarea_size)
    maketextareacode($lang['field_test_ext'], "image_test_".$i, "", $textarea_size );


/includes/functions.php: line  47
 $test = $img_result['image_test'];
 .........
 $site_template->register_vars(array("image_id" => $img_result['image_id'],
                                      "user_id" => $img_result['user_id'],
                                      "image_name" => stripslashes($img_result['image_name']),
                                      "description" => FormatText($description, 1),
                                                                             ------------
                                      "thumbnail_file_name" => $img_result['image_thumb_file'],
                                      "test" => $img_result['image_test']                          
                                      ));
  $rate_form = $site_template->parse_template("rate_form");
  $site_template->register_vars("rate_form", $rate_form);
  return true;
}

/templetes/default/details.html:
        ---------
             <tr>
                                  <td valign="top" class="row1"><b>{lang_description}</b></td>
                                  <td valign="top" class="row1">{description}</td>
                                </tr>
                                <tr>
                                  <td valign="top" class="row2"><b>{lang_keywords}</b></td>
                                  <td valign="top" class="row2">{keywords}</td>
                                </tr>
                               <tr>
                                  <td valign="top" class="row2"><b>{lang_test}</b></td>
                                  <td valign="top" class="row2">{test}</td>
                                </tr>
---------------------

/lang/english/admin.php
lang['field_test'] = "test";
$lang['field_test_ext'] = "test .......";
$lang['field_test_contains'] = "test contains";
$lang['test'] = "test:";

Hope it helps.
-Ofuuzo
Title: Add two fields to the database
Post by: alex2k on April 24, 2002, 10:18:37 AM
Thank's a lot
I'll try it.