4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Tutorials => Topic started by: Ofuuzo on August 06, 2002, 05:21:37 PM

Title: [Tutorial] Making additional field searchable
Post by: Ofuuzo on August 06, 2002, 05:21:37 PM
(http://img517.imageshack.us/img517/7821/eng9tu.gif) - first only a englisch version ...
(http://img517.imageshack.us/img517/1378/deu8yc.gif) - eine deutsche Version kommt bald ... oder später ... ;) ... zwischenzeitlich nutze diese Deutsche-Google-Übersetzung (http://translate.google.com/translate?u=http%3A%2F%2Fwww.4homepages.de%2Fforum%2Findex.php%3Ftopic%3D1313.0&langpair=en%7Cde&hl=de&ie=UTF-8) ...



I have added a field to the database to show not only the keywords, description, date ... . How can I make it searchable just like keywords, and description fields?

Thanks.

- Ofuuzo
Title: [Tutorial] Making additional field searchable
Post by: Jan on August 06, 2002, 05:43:40 PM
In this example, i presuppose that you have added a new field  (http://www.4homepages.de/forum/viewtopic.php?p=3277#3277)called image_photographer.


1. Create a new column in the table 4images_wordmatch called photographer_match
Code: [Select]
ALTER TABLE 4images_wordmatch ADD photographer_match TINYINT(1) DEFAULT '0' NOT NULL;

2.  Open includes/search_utils.php and find this part
Code: [Select]
$search_match_fields = array(
  "image_name" => "name_match",
  "image_description" => "desc_match",
  "image_keywords" => "keys_match"
);
add a new line to the array:
Code: [Select]
$search_match_fields = array(
  "image_name" => "name_match",
  "image_description" => "desc_match",
  "image_keywords" => "keys_match",
  "image_photographer" => "photographer_match"
);
Note the comma added behind the third line!


3. Open main.php in your lang folders and add a new line:
Code: [Select]
$lang['image_photographer_only'] = "Only Photographer";Do this for all your languages!


4. Open the template search_form.html and add this:
Code: [Select]
<input type="radio" name="search_fields" value="image_photographer" /> {lang_image_photographer_only}

5. Rebuild the search index.
You can use the plugin from here (http://www.4homepages.de/forum/index.php?topic=6718.0).

Greets Jan
Title: [Tutorial] Making additional field searchable
Post by: Ofuuzo on August 07, 2002, 12:19:16 PM
That is great great great!!!,

Thank you very very much.

- Ofuuzo
Title: Keywords mistery
Post by: Dmitro on September 01, 2002, 01:08:19 PM
Jan,

I have done all what you wrote above to make one of the fields searcheable. All should be fine, but, I have a misterious problem with some of my keywords:

Short keywords such as 16, 17, 18 do not return any records, while other keywords (longer numbers, such as 1666 and words such as violin, braccio etc ) make the job without any trouble.

What is the problem?

Thanks, indeed.

Dmitry
Title: [Tutorial] Making additional field searchable
Post by: Jan on September 01, 2002, 01:36:26 PM
If you use version 1.7 you can define the min and max searchword length in "includes/constants.php".

Code: [Select]
define('MIN_SEARCH_KEYWORD_LENGTH', 3);
define('MAX_SEARCH_KEYWORD_LENGTH', 25);

After changing that, please rebuild your searchindex.

Greets Jan
Title: [Tutorial] Making additional field searchable
Post by: Dmitro on September 01, 2002, 01:43:38 PM
Dear Jan,
Thanks a lot for your quick reply!
I am not yet using 1.7  - I am still checking how much work I have to do in order to upgrade.
Dmitry
Title: [Tutorial] Making additional field searchable
Post by: Jan on September 01, 2002, 01:52:29 PM
Search for
Code: [Select]
if ($word != "" && strlen($word) > 2 && strlen($word) < 26 && !in_array($word, $stopword_list)) {
in "includes/search_utils.php" and
Code: [Select]
elseif ($split_words[$i] != "" && strlen($split_words[$i]) > 2 && strlen($split_words[$i]) < 26 && !in_array($split_words[$i], $stopword_list)) {
in "search.php" and change "2" to "1".

Jan
Title: Jan is a magician
Post by: Dmitro on September 01, 2002, 02:44:47 PM
Jan, you are a magician.
Thanks. Dmitry :D
Title: [Tutorial] Making additional field searchable
Post by: k4nth on January 28, 2003, 11:06:34 AM
is it possible to include Categories names in search?
Title: [Tutorial] Making additional field searchable
Post by: Jan on January 28, 2003, 03:32:30 PM
No.

Jan
Title: how can i have the image_photographer clickable?
Post by: bernd on March 22, 2003, 09:42:17 PM
to be able to use it just like the keywords? I did the MODs so I have the photographer being shown below the image and I can search for this via the extended search but I'd like my users to be able to just click the photographer's name and they are then shown all pictures taken by this guy.

I tried to find how/where it is done for the keywords but I struggled ...

Thanks in advance!
Bernd
Title: [Tutorial] Making additional field searchable
Post by: Psy on March 28, 2003, 01:40:25 PM
I'm having problems with making these fields searchable

I used the Mod to add extra fields ( 7 extra fields in total ) which worked fine...all the new fields dumped into the db fine and displayed fine.

Next, I followed this Mod to make these new fields searchable, and ran the rebuild search index tool,
witch gave me this error:

Code: [Select]
Processing image qqqqq, ID 9 ... OK
Processing image can, ID 10 ...
DB Error: Bad SQL Query: REPLACE INTO 4images_wordmatch (image_id, word_id, name_match, desc_match, keys_match, edibility_match, habitat_match, range_match, season_match, sporecolor_match, mushroomshape_match, lookalikes_match) VALUES (10, 7, 0, 1, 1, 0), (10, 10, 0, 0, 1, 0)
Column count doesn't match value count at row 1
OK
Processing image asasas, ID 11 ...
DB Error: Bad SQL Query: REPLACE INTO 4images_wordmatch (image_id, word_id, name_match, desc_match, keys_match, edibility_match, habitat_match, range_match, season_match, sporecolor_match, mushroomshape_match, lookalikes_match) VALUES (11, 12, 0, 0, 0, 0), (11, 13, 0, 0, 0, 0), (11, 14, 0, 0, 0, 0), (11, 15, 0, 0, 0, 0)
Column count doesn't match value count at row 1
OK


Search index rebuilt!





I them tried search my new fields, and found that I can search the first extra field I added, get a error when I try to search the rest of the new fields:
Code: [Select]
DB Error: Bad SQL Query: SELECT m.image_id FROM 4images_wordlist w, 4images_wordmatch m WHERE w.word_text LIKE 'rust' AND m.word_id = w.word_id AND m.sporecolor_match = 1
Unknown column 'm.sporecolor_match' in 'where clause'



I them tried to upload a new image, and got this error:
Code: [Select]
DB Error: Bad SQL Query: REPLACE INTO 4images_wordmatch (image_id, word_id, name_match, desc_match, keys_match, edibility_match, habitat_match, range_match, season_match, sporecolor_match, mushroomshape_match, lookalikes_match) VALUES (12, 5, 0, 0, 0, 1), (12, 12, 0, 0, 0, 0), (12, 13, 0, 0, 0, 0), (12, 14, 0, 0, 0, 0), (12, 15, 0, 0, 0, 0)
Column count doesn't match value count at row 1



Can anyone tell me what I'm doing wrong? I understand that this error comes from adding different amount
of values in than there are columns, but I can't see where my error is....any ideas????
Code: [Select]
Quote
[/list:u]
Title: [Tutorial] Making additional field searchable
Post by: Chris on March 28, 2003, 02:44:53 PM
"Column count doesn't match value count at row 1"

It looks to me like you have a mismatch in the number of fields you added to includes/db_field_definitions.php and the number of new database columns you created.  Recheck these.  Either that or you have a mismatch of the types.  IE:  You added a character field and an integer field in the php file but added an integer and then character column in the database table.
Title: [Tutorial] Making additional field searchable
Post by: Psy on March 28, 2003, 10:06:40 PM
Chris - thanks for the quick reply

I've checked everything over 100 time and I still can't see anything wrong. What really gets me is that the first search field I added still works fine, but the rest don't.  :x  :x  :x  :x  :x  :x
Anyone have any other ideas???????? Plaese :cry:
Title: [Tutorial] Making additional field searchable
Post by: V@no on March 28, 2003, 11:26:56 PM
I didnt follow the discussion here :? but, just a thought:
Quote
DB Error: Bad SQL Query: REPLACE INTO 4images_wordmatch (1 image_id, 2 word_id, 3 name_match, 4 desc_match, 5 keys_match, 6 edibility_match, 7 habitat_match, 8 range_match, 9 season_match, 10 sporecolor_match, 11 mushroomshape_match, 12 lookalikes_match) VALUES 1 (12, 5, 0, 0, 0, 1), 2 (12, 12, 0, 0, 0, 0), 3 (12, 13, 0, 0, 0, 0), 4 (12, 14, 0, 0, 0, 0), 5 (12, 15, 0, 0, 0, 0)
Column count doesn't match value count at row 1

colored numbers are just count how many fields u are tryin  to update, and how many values. so, I'd say that the mismatch: 12 fields, but only 5 of them set values.
Title: Re: [Tutorial] Making additional field searchable
Post by: titi-fr on March 25, 2005, 12:34:32 PM
here the sample of my rebuilt :

Code: [Select]
Processing image Villa Traditionnelle RUY – 2 min. A 43 - 338 000 €, ID 3 ...
DB Error: Bad SQL Query: REPLACE INTO 4images_wordmatch (image_id, word_id, name_match, desc_match, keys_match, prix_match) VALUES (3, 181, 1, 1, 0), (3, 1204, 1, 1, 0), (3, 183, 1, 0, 0), (3, 184, 1, 0, 0), (3, 1205, 1, 1, 0), (3, 21, 1, 1, 0), (3, 18, 0, 1, 0), (3, 1206, 0, 1, 0), (3, 22, 0, 1, 0), (3, 23, 0, 1, 0), (3, 1022, 0, 1, 0), (3, 188, 0, 1, 0), (3, 189, 0, 1, 0), (3, 1023, 0, 1, 0), (3, 191, 0, 1, 0), (3, 1207, 0, 1, 0), (3, 27, 0, 1, 0), (3, 1208, 0, 1, 0), (3, 778, 0, 1, 0), (3, 35, 0, 1, 0), (3, 195, 0, 1, 0), (3, 196, 0, 1, 0), (3, 1209, 0, 1, 0), (3, 36, 0, 1, 0), (3, 198, 0, 1, 0), (3, 40, 0, 1, 0), (3, 1210, 0, 1, 0), (3, 1211, 0, 1, 0), (3, 1212, 0, 1, 0), (3, 11, 0, 1, 0), (3, 202, 0, 1, 0), (3, 203, 0, 1, 0), (3, 204, 0, 1, 0), (3, 1030, 0, 1, 0), (3, 1213, 0, 1, 0), (3, 1214, 0, 1, 0), (3, 1215, 0, 1, 0), (3, 688, 0, 0, 1)
Column count doesn't match value count at row 1
OK
Processing image Ferme rénovée la verpillière 327 000 €, ID 2 ...
DB Error: Bad SQL Query: REPLACE INTO 4images_wordmatch (image_id, word_id, name_match, desc_match, keys_match, prix_match) VALUES (2, 151, 1, 1, 0), (2, 152, 1, 0, 0), (2, 724, 1, 0, 0), (2, 725, 1, 1, 0), (2, 21, 1, 1, 0), (2, 17, 0, 1, 0), (2, 18, 0, 1, 0), (2, 726, 0, 1, 0), (2, 22, 0, 1, 0), (2, 23, 0, 1, 0), (2, 727, 0, 1, 0), (2, 728, 0, 1, 0), (2, 158, 0, 1, 0), (2, 27, 0, 1, 0), (2, 729, 0, 1, 0), (2, 730, 0, 1, 0), (2, 731, 0, 1, 0), (2, 732, 0, 1, 0), (2, 733, 0, 1, 0), (2, 33, 0, 1, 0), (2, 734, 0, 1, 0), (2, 35, 0, 1, 0), (2, 36, 0, 1, 0), (2, 37, 0, 1, 0), (2, 163, 0, 1, 0), (2, 164, 0, 1, 0), (2, 40, 0, 1, 0), (2, 41, 0, 1, 0), (2, 42, 0, 1, 0), (2, 11, 0, 1, 0), (2, 165, 0, 1, 0), (2, 735, 0, 1, 0), (2, 167, 0, 1, 0), (2, 736, 0, 1, 0), (2, 688, 0, 0, 1)
Column count doesn't match value count at row 1

i've added 3 fields in images wordmatch :x but only "prix" appeared...
Title: Re: [Tutorial] Making additional field searchable
Post by: V@no on March 25, 2005, 02:27:14 PM
on some servers u can not use non-latin letters...its a server side configuration (mysql)
Title: Re: [Tutorial] Making additional field searchable
Post by: titi-fr on March 25, 2005, 02:29:54 PM
u mean like that: é à etc ?

th fields who doesnt appears are name reference & code, not non-latin
Title: Re: [Tutorial] Making additional field searchable
Post by: TIMT on March 28, 2005, 09:54:41 AM
I don't know why... but it doesn't work..   :(

I have implemented two additionales files: user_vorname and user_name2.

I have entered the two fields name2_match and vorname_match in the table 4images_wordmatch in my database

In search_utils.php I have entered the following code:
Code: [Select]
$search_match_fields = array(
  "image_name" => "name_match",
  "image_description" => "desc_match",
  "image_keywords" => "keys_match",
  "user_vorname" => "vorname_match",
  "user_name2" => "name2_match"

In main.php I have entered the following code:
Code: [Select]
$lang['user_name2_only'] = "Nur Name";
$lang['user_vorname_only'] = "Nur Vorname";

In search_form.html I have entered the following code:
Code: [Select]
<tr>
                  <td nowrap="nowrap" class="td2"><input type="radio" name="search_fields" value="user_vorname" /> {lang_user_vorname_only}</td>
                  <td nowrap="nowrap">&nbsp;</td>
                  <td nowrap="nowrap" class="td2"><input type="radio" name="search_fields" value="user_name2" /> {lang_user_name2_only}</td>               
                </tr>

Than I rebuilded the search index.

On the search-sreen I can see the new radio buttons, but not the description of the radio buttons (regarding the entry in main.php).
The search of "user_name2" or "user_vorname" doesn't work.

Where is the problem?

Thank you for helping me!
Serge
Title: Re: [Tutorial] Making additional field searchable
Post by: V@no on March 28, 2005, 02:33:45 PM
1) make sure u've updated includes/db_fields_definitions.php
2) the search_form is wrong, it should be in this format:
Code: [Select]
              <input type="radio" name="user_vorname" value="1"{user_vorname_yes} />
              {lang_yes}&nbsp;&nbsp;&nbsp;
              <input type="radio" name="user_vorname" value="0"{user_vorname_no} />
              {lang_no}
But its hard to tell what exactly are u planning to do...
Title: Re: [Tutorial] Making additional field searchable
Post by: TIMT on March 28, 2005, 09:29:51 PM
I'd like to offer the possibility to search for "user_name2" and "user_vorname" (first name).

I have entered in db_field_definitions the following code:
Code: [Select]
$additional_user_fields['user_vorname'] = array($lang['user_vorname'], "text", 1);
$additional_user_fields['user_name2'] = array($lang['user_name2'], "text", 1);

In the profile I can enter the first- and last name. The information is stored correctly in the database. That is not the problem.

But now I want to search after "user_name2" and "user_vorname". And that doesn't work.

I entered the code in search_form.html as it is mentioned in the tutorial.

So I'm a little bit confused about your proposal. What should I do?

Sorry, I have no idea about PHP....

Thank you for helping me.

Serge
Title: Re: [Tutorial] Making additional field searchable
Post by: V@no on March 28, 2005, 09:37:49 PM
I dont think u can do it with radio type of input...u'll need add two separate input forms for first and last names...
Code: [Select]
<input type="text" name="user_vorname" value="" />
Title: Re: [Tutorial] Making additional field searchable
Post by: TIMT on March 28, 2005, 10:30:17 PM
that's fine! Do I have to change the field in the database, table 4images_wordmatch ?
is the rest of the instruction regarding the turorial ok?

unfortunately the serach doesn't work. is it possible to enter "user_vorname" and "user_name2" for a single search (e.g. a serach after "Tom Till")

here is the code of my search_form.html

Code: [Select]
<form method="post" action="{url_search}">
  <table width="100%" border="0" cellspacing="0" cellpadding="1">
    <tr>
      <td class="head1">
        <table width="100%" border="0" cellpadding="4" cellspacing="0">
          <tr>
            <td colspan="2" valign="top" class="head1">{lang_search}</td>
          </tr>
         
          <tr>
                  <td valign="top" class="row2"><b>Vorname</b></td>
                  <td class="row2" valign="top">
                  <input class="logininput" type="text" name="user_vorname" value="" /> </td>
                </tr>
                <tr>   
                  <td valign="top" class="row2"><b>Nachname</b></td>
                  <td class="row2" valign="top">
                  <input class="logininput" type="text" name="user_name2" value="" /> </td> 
                </tr>
         
         
          <tr>
            <td valign="top" class="row1"><b>{lang_search_by_keyword}</b></td>
            <td class="row1" valign="top">
              <input type="text" name="search_keywords" size="40" value="{search_keywords}" class="input" />
              <br />
              <input type="checkbox" name="search_new_images" value="1" />
              {lang_new_images_only}</td>
          </tr>
  <tr>
            <td valign="top" class="row2"><b>{lang_search_by_username}</b></td>
            <td class="row2" valign="top">
              <input type="text" name="search_user" size="40" value="{search_user}" class="input" />
            </td>
          </tr>
          <tr>
            <td class="row1"><b>{lang_search_terms}</b></td>
            <td class="row1">
              <input type="radio" name="search_terms" value="all" checked="checked" />
              {lang_and}&nbsp;&nbsp;
              <input type="radio" name="search_terms" value="any" />
              {lang_or}
            </td>
          </tr>
          <tr>
            <td class="row2"><b>{lang_category}</b></td>
            <td class="row2">{category_dropdown}</td>
          </tr>
          <tr>
            <td valign="top" class="row1"><b>{lang_search_fields}</b></td>
            <td class="row1">
              <table border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td nowrap="nowrap" class="td2"><input type="radio" name="search_fields" value="all" checked="checked" /> {lang_all_fields}</td>
                  <td nowrap="nowrap">&nbsp;&nbsp;&nbsp;&nbsp;</td>
                  <td nowrap="nowrap" class="td2"><input type="radio" name="search_fields" value="image_name" /> {lang_name_only}</td>
                </tr>
                <tr>
                  <td nowrap="nowrap" class="td2"><input type="radio" name="search_fields" value="image_description" /> {lang_description_only}</td>
                  <td nowrap="nowrap">&nbsp;</td>
                  <td nowrap="nowrap" class="td2"><input type="radio" name="search_fields" value="image_keywords" /> {lang_keywords_only}</td>
              </table>
            </td>
          </tr>
          <tr>
            <td class="row1">&nbsp;</td>
            <td class="row1"><input type="submit" value="{lang_search}" class="button" /></td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</form>
Title: Re: [Tutorial] Making additional field searchable
Post by: TIMT on March 29, 2005, 11:20:30 PM
Can anybody help me?

Thank you!

Serge
Title: Re: [Tutorial] Making additional field searchable
Post by: TIMT on March 31, 2005, 09:14:48 AM
Hi V@no

May be you can give me a hint...  :?:

Thank you!
Serge
Title: Re: [Tutorial] Making additional field searchable
Post by: TIMT on April 01, 2005, 09:37:21 AM
I tried again to find a hint to solve my problem.
I found the following post:
http://www.4homepages.de/forum/index.php?topic=2168.0

Unfortunately the mentioned links on this post are not active anymore....

So I'm still sitting on my problem...   :cry:

I hope, somebody will help me soon..

Thank you!
Title: Re: [Tutorial] Making additional field searchable
Post by: TIMT on April 05, 2005, 12:02:49 PM
maybe I'm invisible...  :roll:
Title: Re: [Tutorial] Making additional field searchable
Post by: TIMT on April 06, 2005, 10:16:51 PM
The only thing I want is making new fields searchable. And I did what it is mentioned in the tutorial.
Or have I something misunderstood?

Title: Re: [Tutorial] Making additional field searchable
Post by: ascanio on April 11, 2005, 01:44:37 AM
This is what I have done:

I have created a new column in the table 4images_wordmatch called user_city_match

Then I add this
Code: [Select]
$search_match_fields = array(
  "image_name" => "name_match",
  "image_description" => "desc_match",
  "image_keywords" => "keys_match",
  "user_city" => "user_city_match"
);

then this:
Code: [Select]
$lang['user_city_only'] = "City only";
Then this:

Code: [Select]
<td nowrap="nowrap"><input type="radio" name="search_fields" value="user_city" /> {lang_user_city_only}</td>

I did a Search index rebuilt and I got this

Code: [Select]
DB Error: Bad SQL Query: INSERT INTO girls_wordmatch (image_id, word_id, name_match, desc_match, keys_match, user_city_match) SELECT DISTINCT 7028, word_id, 1, 0, 0, 0 FROM girls_wordlist WHERE word_text = 'fotografia'
Duplicate entry '7028-1531' for key 1

I aslo don't see City only in the search_form.html

What I did wrong?
Title: Re: [Tutorial] Making additional field searchable
Post by: TIMT on April 24, 2005, 09:48:10 PM
Hi everybody

I have added two new fields in the database
firstname
lastname
the two new fields can be entered in "edit profile". That's ok!

Now I'd like make the two new fields searchable.

I did all modification but it doesn't work. Please also see the information above.
What did I wrong?

Thank you for helping me!

Serge
Title: Re: [Tutorial] Making additional field searchable
Post by: Jan on April 25, 2005, 04:08:08 PM
You can't make the fields searchable because they are in the users tabel and not in the images table. The last error message is because you maybe didn't emptied the indes before the rebuild.

Jan
Title: Re: [Tutorial] Making additional field searchable
Post by: TIMT on April 27, 2005, 10:02:27 PM
Is it possible to make a new field searchable in the users table?
Or means that a lot of modifications?
Title: Re: [Tutorial] Making additional field searchable
Post by: Jan on April 28, 2005, 05:20:00 PM
Yes, you have to do it similar to the username search on top of search.php.

Jan
Title: Re: [Tutorial] Making additional field searchable
Post by: TIMT on April 28, 2005, 05:43:57 PM
Can you post the code? That would be great!! 



Title: Re: [Tutorial] Making additional field searchable
Post by: Jan on April 29, 2005, 02:02:38 PM
The easiest way is to replace

Code: [Select]
WHERE ".get_user_table_field("", "user_name")." LIKE '$search_user'";
with

Code: [Select]
WHERE ".get_user_table_field("", "user_name")." LIKE '$search_user' OR ".get_user_table_field("", "firstname")." LIKE '$search_user' OR ".get_user_table_field("", "lastname")." LIKE '$search_user'";
After that, you can enter in the user search field the username OR the firstname OR the lastname.

Jan
Title: Re: [Tutorial] Making additional field searchable
Post by: TIMT on April 29, 2005, 03:35:24 PM
I have the mentioned line replaced with the following code :

Code: [Select]
WHERE ".get_user_table_field("", "user_name")." LIKE '$search_user' OR ".get_user_table_field("", "user_vorname")." LIKE '$search_user' OR ".get_user_table_field("", "user_name2")." LIKE '$search_user'";
user_vorname and user_name2 are the fields in the database.

when I enter a value in the search field for "search user" I get the following message:

DB Error: Bad SQL Query: SELECT user_id FROM 4images_users WHERE user_name LIKE 'serge' OR LIKE 'serge' OR LIKE 'serge'
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIKE 'serge' OR LIKE 'serge'' at line 4

What did I wrong?
Title: Re: [Tutorial] Making additional field searchable
Post by: Jan on April 29, 2005, 04:33:24 PM
Nothing, i did it wrong ;)

Use:

Code: [Select]
WHERE ".get_user_table_field("", "user_name")." LIKE '$search_user' OR user_vorname LIKE '$search_user' OR  user_name2 LIKE '$search_user'";
Title: Re: [Tutorial] Making additional field searchable
Post by: TIMT on April 29, 2005, 04:53:37 PM
Thank you Jan!
Once more... great support.   :D

Serge
Title: Re: [Tutorial] Making additional field searchable
Post by: ascanio on May 01, 2005, 02:01:01 AM
hi can we search by user_gender in the user gender table?
Title: Re: [Tutorial] Making additional field searchable
Post by: Sopur on May 02, 2005, 05:30:02 PM
Hello!
I don't want exactly the same, but it goes into the same direction: I would like to have the comments also been searched. Is this possible?
(Deutsch: ich möchte gerne, dass die Kommentare auch durchsucht werden. Auch schon, wenn man einfach in dem einfachen Suchfeld oben einen Begriff eingibt. Ist das möglich?)
M
F
G
Sopur
Title: Re: [Tutorial] Making additional field searchable
Post by: WhiteRabbit on August 01, 2005, 03:39:17 AM
Hello.

First and mainly, thanks for this mod. Its really very helpful to my purposes (site on-line soon...).

And, a question:

I'm adding a boolean field. And I want to make it searchable. The question is: I have to add a new column -with the field's name- to the wordmach table?.

And, if somebody wants to add a boolean field, here is the format for the member_uploadform.html (replace "nocturnal" with the name of your choice...):

Code: [Select]
          <tr>
           <td class="row2" valign="top"><b>{lang_image_nocturnal}</b></td>
   <td class="row2"> <input type="radio" name="image_nocturnal" value="1"> {lang_yes}&nbsp;&nbsp;&nbsp;<input type="radio" name="image_nocturnal" value="0" checked="checked"> {lang_no} </p></td>
          </tr>

Thanks in advance.

Best Regards.
WR.
Title: Re: [Tutorial] Making additional field searchable
Post by: WhiteRabbit on August 04, 2005, 03:27:17 AM
Hello again.

Well, I did find out by myself... check this post:

http://www.4homepages.de/forum/index.php?topic=9148.msg42890#msg42890

Best regards.
WR.
Title: Re: [Tutorial] Making additional field searchable
Post by: hinzwiekunz on August 30, 2005, 12:00:51 AM
Sorry for double postings. Its really nessesary to find the solution. Could somebody give a hint....


It doesn't work for me. Perhaps there is a special value for me anywhere.

 I have added a field "image_license" and can use it with the images. it works. but i couldnt search for images with only this activated values.
Here is the actual test-site:
http://www.hinzwiekunz.de/gallerytest/


Quote
1. Create a new column in the table 4images_wordmatch called photographer_match
Code: [Select]
ALTER TABLE 4images_wordmatch ADD photographer_match TINYINT(1) DEFAULT '0' NOT NULL;

I have created a table 4images_wordmatch called license_match like this. No problem. I dont know if the values '0' and NOT NULL are right for me.


Quote
2.  Open includes/search_utils.php and find this part...

My Code is like this:
Code: [Select]
$search_match_fields = array(
  "image_name" => "name_match",
  "image_description" => "desc_match",
  "image_keywords" => "keys_match",
  "image_license" => "license_match"
);

Quote
b]3.[/b] Open main.php in your lang folders and add a new line:

I have done it, but I think thats not the problem.

Quote
4. Open the template search_form.html and add this:
Code: [Select]
<input type="radio" name="search_fields" value="image_photographer" /> {lang_image_photographer_only}

Code: [Select]
<td>
                  <input type="radio" name="image_license" value="{image_license_yes}" />
      {lang_search_licensed}</td>
              </tr>
              <tr>
                <td>
                  <input type="radio" name="image_license" value="{image_license_no}" />
      {lang_search_licensefree}</td>
I tried many variations with the value-Tag, e.g. Vano has said...
Code: [Select]
value="1"{image_license_yes}, but nothing has changed.

Code: [Select]
[b]5.[/b] Rebuild the search index.Done.
Title: Re: [Tutorial] Making additional field searchable
Post by: hinzwiekunz on August 31, 2005, 07:33:36 AM
Could there anybody give me a hint?  :cry:
I expect that the mistake ist in search_form, but I tried many versions to use the values.

And I didnt get any errors. Even the Search rebuilt was without error, so it is not to compare with the other postings here. I dont know...

markus
Title: Re: [Tutorial] Making additional field searchable
Post by: Jan on August 31, 2005, 01:39:07 PM
The search index should be used for kind of fulltext searches. You misunderstood how it works.
If you want to make you new field searchable, you should have add it like:

Code: [Select]
<input type="radio" name="search_fields" value="image_license" />
In this case you could check the radio and type "1" in the searchfield to find all images who have a value "1" for that field.
Title: Re: [Tutorial] Making additional field searchable
Post by: hinzwiekunz on September 01, 2005, 12:19:10 AM
Hi Jan,
thanks for your answer. I tried, but it dont work. It dont find my images with this values.
For me its important to have the choice to search for images with this new image_license-value "0" and images with value "1" in combination with the keywords.
I tried again like Vano:
Code: [Select]
<input type="radio" name="search_fields" value="image_license_yes" /><br><input type="radio" name="search_fields" value="image_license_no" />But there is no changing.

In Deutsch.
Vielen Dank noch mal, Jan. Es hat allerdings noch nicht geklappt. Auch so finde ich mit der Suche nicht die Bilder mit den ensptrechenden Werten.
Ich möchte nach Lizenzfreien und Lizensierten in der Suche unterscheiden können und diese Bildeigenart, eigentlich nach Bedarf zuschalten können - deswegen dachte ich den radio-namen anders zu wählen. Eine Kopplung an die anderen search_fields ist ok, aber es funkioniert auch so nicht. Auf jedenfall wäre mir wichtig nach image_license_yes und _no als Button zu unterscheiden. Vano hatte das auch ähnlich vorgeschlagen.
Es funkionert nur alles nicht, obwohl die einzelnen Bilder schon wunderbar eingestellt und bearbeitet werden können. Ich habe drei Test-Bilder mit dem Keyword test versehen. Ein Bild ist lizenzfrei, zwei andere sind mit dem Keyword "test" lizensiert. Super klappt die unterschiedliche Darstellung von Informationen jeweils bei lizensierten und lizenzfreien Bildern.

Code: [Select]
{if image_license}<strong>Lizensiert</strong><br>                              <table width="100%"  border="0" cellpadding="0" cellspacing="4">
                                <tr>
                                  <td class="title">&nbsp;</td>
                                  <td valign="top">F&uuml;r eine Verwendung dieses Bildes machen wir Ihnen ein konkretes Angebot. Bitte klicken Sie auf den Anfragebutton und f&uuml;llen das Formular aus. </td>
                                  <td align="right" valign="top"><span class="rowsearch"><a href="index.php?template=preise">{hilfe_button}</a></span></td>
                                </tr>
                                <tr>
                                  <td class="title"><img src="{template_url}/images/spacer.gif" alt="" width="25" height="5" /></td>
                                  <td>&nbsp;</td>
                                  <td>&nbsp;</td>
                                </tr>
                                <tr>
                                  <td class="title">&nbsp;</td>
                                  <td><a href="http://www.hinzwiekunz.de/gallerytest/anfrage.php?cat_id={cat_id}&image_file_name={image_file_name}" target="Anfrage" onClick="MM_openBrWindow('anfrage.php','Anfrage','toolbar=yes,scrollbars=yes,resizable=yes,width=530,height=630')">{anfrage_button}</a></td>
                                  <td>&nbsp;</td>
                                </tr>
                              </table>                             
                              {endif image_license}{ifno image_license}<strong>Lizenzfrei
                              </strong><br>                              <table width="100%"  border="0" cellpadding="0" cellspacing="4">
                                <tr>
                                  <td class="title"><img src="{template_url}/images/spacer.gif" alt="" width="25" height="5" /></td>
                                  <td valign="top">Dieses Bild ist lizenzfrei zu folgenden Preisen zu erwerben.</td>
                                  <td align="right" valign="top"><span class="rowsearch"><a href="index.php?template=preise">{hilfe_button}</a></span></td>
                                </tr>
                                <tr>
                                  <td class="title">&nbsp;</td>
                                  <td><table  border="0" cellpadding="0">
                                    <tr>
                                      <td><p>&nbsp;</p></td>
                                      <td>&nbsp;</td>
                                      <td>&nbsp;</td>
                                      <td>&nbsp;</td>
                                      <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <td class="title">Web</td>
                                      <td><img src="{template_url}/images/spacer.gif" alt="" width="25" height="5" /></td>
                                      <td>900 x 600 Pixel bei 72 dpi</td>
                                      <td><img src="{template_url}/images/spacer.gif" alt="" width="25" height="5" /></td>
                                      <td>40 &euro;</td>
                                    </tr>
                                    <tr>
                                      <td class="title">A5</td>
                                      <td>&nbsp;</td>
                                      <td>ca. A5-Format bei 300 dpi</td>
                                      <td>&nbsp;</td>
                                      <td>90 &euro; </td>
                                    </tr>
                                    <tr>
                                      <td class="title">A4</td>
                                      <td>&nbsp;</td>
                                      <td>ca. A4-Format bei 300 dpi</td>
                                      <td>&nbsp;</td>
                                      <td>120 &euro;</td>
                                    </tr>
                                    <tr>
                                      <td class="title">A3</td>
                                      <td>&nbsp;</td>
                                      <td>ca. A3-Format bei 300 dpi</td>
                                      <td>&nbsp;</td>
                                      <td>180 &euro;</td>
                                    </tr>
                                  </table></td>
                                  <td>&nbsp;</td>
                                </tr>
                                <tr>
                                  <td class="title"><img src="{template_url}/images/spacer.gif" alt="" width="25" height="5" /></td>
                                  <td>&nbsp;</td>
                                  <td>&nbsp;</td>
                                </tr>
                                <tr>
                                  <td class="title">&nbsp;</td>
                                  <td><a href="http://www.hinzwiekunz.de/gallerytest/bestellen.php?cat_id={cat_id}&image_file_name={image_file_name}" target="Bestellung" onClick="MM_openBrWindow('bestellen.php','Bestellen','toolbar=yes,scrollbars=yes,resizable=yes,width=530,height=630')">{bestellen_button}</a></td>
                                  <td>&nbsp;</td>
                                </tr>
                              </table>

??????
Title: Re: [Tutorial] Making additional field searchable
Post by: Jan on September 02, 2005, 04:47:18 PM
Nee, ich glaube Du hast das Prinzip noch nicht verstanden ;) Nicht böse gemeint :)
Hab leider momentan keine Zeit das zu programmieren. Evtl. bekommst Du es alleine raus indem Du Dich in search.php und global.php an $search_new_images orientierst.
Title: Re: [Tutorial] Making additional field searchable
Post by: hinzwiekunz on September 06, 2005, 12:38:45 AM
Hi Jan,
du hast recht. Wie das alles in 4images miteinander verknüpft ist bei der suche verstehe ich nicht so richtig. Ich hatte es mir nicht so schwierig vorgestellt. Danke für die Tips, aber ich steige da nicht so richtig durch...
Ich habe jetzt erst alles umgestellt ohne Suche, wäre aber SEHR daran interessiert, bald die Suche zu ermöglichen...  :roll:

Gruß,
Markus
Title: Re: [Tutorial] Making additional field searchable
Post by: Jan-Lukas on September 25, 2005, 09:15:58 AM
Hi,
habe meine Suche jetzt erweitert
Nur wenn im Suchwort jetzt ein - enthalten ist, findet er dieses Bild nicht.

Bei uns gibt es aber BPZ Nummern, die ein - enthalten z.B. S-1 oder auch Serien Namen mit _ oder auch Piratelli - Käpt´n Knautsch

wäre schön wenn ihr mir da einen Tip geben könntet

Ansonsten klappt alles Super

gruss Harald

Ps. habe ein Test Bild erstellt
http://www.mr-marker.de/4images/details.php?image_id=10714

Edit: habe jetzt rausgefunden das die Suche bei z.B. S-1 nicht klappt, aber bei C-107 klappt es bestens.
Kann es sein das zur suche mehr als 3 Einträge nötig sind ?
hat also nichts mit dem minus Zeichen zu tun das es nicht geht.
und wenn ja, kann man dieses ändern?

gruss Harald


Title: Re: [Tutorial] Making additional field searchable
Post by: Jan on September 26, 2005, 04:30:50 PM
Siehe includes/constants.php

Code: [Select]
define('MIN_SEARCH_KEYWORD_LENGTH', 3);
Das "-" wird nicht als Zeichen gewertet und ausgefiltert.
Title: Re: [Tutorial] Making additional field searchable
Post by: Jan-Lukas on September 28, 2005, 01:03:57 AM
Hi Jan,
Danke,
Aber habe es auf 2 gestellt, und will immer noch nicht gefunden werden  :cry:
vielleicht noch eine Stelle im Skript ?

gruss Harald

Edit: Sorry mein Fehler, hatte das Testbild wieder gelöscht  :wink:
Danke
Title: Re: [Tutorial] Making additional field searchable
Post by: hinzwiekunz on September 30, 2005, 05:43:27 PM
Nee, ich glaube Du hast das Prinzip noch nicht verstanden ;) Nicht böse gemeint :)
Hab leider momentan keine Zeit das zu programmieren. Evtl. bekommst Du es alleine raus indem Du Dich in search.php und global.php an $search_new_images orientierst.


Hallo Jan,

nach Urlaub - muss ich nun wieder ran ans Formular. Hier eine Beispielseite, wie ich mir das vorgestellt hatte mit den voneinander getrennten Suchmöglichkeiten. Super gelöst... Ich habs so noch nicht gepackt.
Gruß,
markus
Title: Re: [Tutorial] Making additional field searchable
Post by: trez on February 10, 2006, 11:02:05 AM
I followed the thread, i have a small question.

For example i make the "user_sex" and "user_location" field from the GIS MOD searchable, how do i make that field in the search with radiobuttons.

For example, seaarch usergender - o male / o female


?
Title: Re: [Tutorial] Making additional field searchable
Post by: Stoleti on October 09, 2006, 02:53:50 AM
I'm using dreamboard ,and i would know how make the search form search for results at board, how added:

Table: 4images_boardtind  => thrtopic

Or if this isnt possible, a external script to search at this specific table  :oops:
Title: Re: [Tutorial] Making additional field searchable
Post by: Hein on October 24, 2006, 12:26:33 PM
Nothing, i did it wrong ;)

Use:

Code: [Select]
WHERE ".get_user_table_field("", "user_name")." LIKE '$search_user' OR user_vorname LIKE '$search_user' OR  user_name2 LIKE '$search_user'";

Hallo,

ich nutze diesen Tip von Jan in abgewandelter Form für meine Memberlist, speziell für eine Usergroup. Nun funktioniert die Suchfunktion nach Mitgliedern schon mit 3 verschiedenen Feldern:

[qcode]$condition = " AND ".$additional_sql." u.user_nachname LIKE '".addslashes($filter_db)."' OR
".$additional_sql." u.user_vorname LIKE '".addslashes($filter_db)."' OR
".$additional_sql." u.user_artistname LIKE '".addslashes($filter_db)."'";
[/qcode]

Allerdings wird bei den zwei zusätzlichen Feldern mit der OR-Funktion, die group_id nicht berücksichtigt und somit werden als Suchergebnis auch Mitglieder anderer Usergruppen ungewollt mit angezeigt. Bei der Suche nach user_nachname in der AND-Bedingung klappt alles wie gewollt!

Wie bekomme ich trotz der OR Funktion das Probleme gelöst?
Title: Making additional field searchable & DB Error after saving modification of a pic
Post by: shadowhunter on April 11, 2008, 02:05:23 PM
Hallo!

Ich möchte in nächster Zeit von PHP 4.4.7 auf PHP 5 umsteigen.
Die 4images Galerie läuft auf PHP 4.4.7 & gemieteten Linux-Server perfekt ohne Fehler.

Jetzt habe ich meine Galerie auf PHP 5 einmal testen wollen. Dazu nahm ich das Tool 4images Mobile Server mit PHP 5.2.3.
Leider kommen ab jetzt immer die folgenden Fehler:

Code: [Select]
DB Error: Bad SQL Query: REPLACE INTO 4images_wordmatch (image_id, word_id, name_match, desc_match, keys_match, gmap_match) VALUES (6, 122, 1, 1, 1), (6, 115, 0, 0, 1), (6, 134, 0, 0, 1), (6, 132, 0, 0, 1)
Column count doesn't match value count at row 1
Bild erfolgreich bearbeitet
oder ein anderes Beispiel:
Code: [Select]
DB Error: Bad SQL Query: REPLACE INTO 4images_wordmatch (image_id, word_id, name_match, desc_match, keys_match, gmap_match) VALUES (6, 8, 1, 0, 1), (6, 9, 0, 0, 1)
Column count doesn't match value count at row 1

Diese Fehler kommen beim Uploaden von Bildern immer, beim Bearbeiten von Bildern (admin/images.php) nur manchmal.

Ich habe alles nach den folgenden Anleitungen gemacht:
- Google-Maps Integration V.01  http://www.4homepages.de/forum/index.php?topic=16533.0
- Making additional field searchable  http://www.4homepages.de/forum/index.php?topic=1313.msg5562#msg5562

in includes/constants.php
Code: [Select]
define('MIN_SEARCH_KEYWORD_LENGTH', 3);  ersetzt durch 
Code: [Select]
define('MIN_SEARCH_KEYWORD_LENGTH', 1);
Das Plugin "Rebulid Search Index" funktioniert auch nicht resp. es gibt änliche Errors raus. (Habe auch "If you are reindexing, you may want to empty the indexes" durchgeführt, jedoch erfolglos.

Ich brauche unbedingt Hilfe, da ich auf PHP 5 umstellen möchte (aber mit diesen Fehlern nicht umstellen kann).
Auf PHP 4 läuft alles super ohne Fehler.
Vielen, vielen Dank im Voraus.

Grüsse Jones



Testsystem:
4images Mobile Server PHP5 version (http://www.4homepages.de/forum/index.php?topic=18352.msg113964#msg113964)
PHP 5.2.3
Apache 2.0.59
PhpMyAdmin 2.11.5

includes/db_field_definitions.php
Code: [Select]
// >>>>>>>>>>>>>>>>>> [MOD] Google-Map >>>>>>>>>>>>>>>>>>
// Additional fields for Google-Maps:
$additional_image_fields['image_gmap_latitude'] = array($lang['image_gmap_latitude'], "text", 0);
$additional_image_fields['image_gmap_longitude'] = array($lang['image_gmap_longitude'], "text", 0);
$additional_image_fields['image_gmap_zoom'] = array($lang['image_gmap_zoom'], "text", 0);
$additional_image_fields['image_gmap_type'] = array($lang['image_gmap_type'], "text", 0);
$additional_image_fields['image_gmap_show'] = array($lang['image_gmap_show'], "radio", 1)

includes/search_utils.php
Code: [Select]
$search_match_fields = array(
  "image_name" => "name_match",
  "image_description" => "desc_match",
  "image_keywords" => "keys_match",
  "image_gmap_show" => "gmap_match"
);

DB-Eintrag bei PHP 5 auf 4images Mobile Server
Code: [Select]
-- Tabellenstruktur für Tabelle `4images_wordmatch`

CREATE TABLE `4images_wordmatch` (
  `image_id` int(10) unsigned NOT NULL default '0',
  `word_id` int(10) unsigned NOT NULL default '0',
  `name_match` tinyint(1) NOT NULL default '0',
  `desc_match` tinyint(1) NOT NULL default '0',
  `keys_match` tinyint(1) NOT NULL default '0',
  ` gmap_match` tinyint(1) NOT NULL default '0',
  UNIQUE KEY `image_word_id` (`image_id`,`word_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Code: [Select]
Tabellenstruktur für Tabelle `4images_images`

CREATE TABLE `4images_images` (
  `image_id` int(10) unsigned NOT NULL auto_increment,
  `cat_id` int(10) unsigned NOT NULL default '0',
  `user_id` int(11) NOT NULL default '0',
  `image_name` varchar(255) NOT NULL default '',
  `image_description` text NOT NULL,
  `image_keywords` text NOT NULL,
  `image_date` int(11) unsigned NOT NULL default '0',

(..................)

  `image_gmap_longitude` varchar(20) NOT NULL,
  `image_gmap_latitude` varchar(20) NOT NULL,
  `image_gmap_zoom` char(2) default '13',
  `image_gmap_type` tinyint(1) NOT NULL default '3',
  `image_gmap_show` tinyint(1) NOT NULL default '0',

(..................)

  PRIMARY KEY  (`image_id`),
  KEY `cat_id` (`cat_id`),
  KEY `user_id` (`user_id`),
  KEY `image_date` (`image_date`),
  KEY `image_active` (`image_active`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

MODs:
- Google-Maps Integration V.01  http://www.4homepages.de/forum/index.php?topic=16533.0
- Making additional field searchable  http://www.4homepages.de/forum/index.php?topic=1313.msg5562#msg5562
- Batch Copy/Move/Edit Images 4.0 for 1.7.4 - 1.7.6  http://www.4homepages.de/forum/index.php?topic=20501.0
- Plugin - Rebulid Search Index
- Auto image resize on upload
- weitere...
Title: Re: [Tutorial] Making additional field searchable
Post by: Jan on April 11, 2008, 05:59:24 PM
Code: [Select]
CREATE TABLE `4images_wordmatch` (
  `image_id` int(10) unsigned NOT NULL default '0',
  `word_id` int(10) unsigned NOT NULL default '0',
  `name_match` tinyint(1) NOT NULL default '0',
  `desc_match` tinyint(1) NOT NULL default '0',
  `keys_match` tinyint(1) NOT NULL default '0',
  ` gmap_match` tinyint(1) NOT NULL default '0',
  UNIQUE KEY `image_word_id` (`image_id`,`word_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Hier liegt der Fehler:
Code: [Select]
` gmap_match` tinyint(1) NOT NULL default '0',
Das Tabellenfeld gmap_match hat ein führendes Leerzeichen. Das ist bei neueren MySQL-Versionen möglich und passiert manchmal wenn man zB mit phpMyAdmin arbeitet.
Title: Re: [Tutorial] Making additional field searchable
Post by: shadowhunter on April 11, 2008, 07:01:35 PM
Hallo Jan
Danke für deine Hilfe! Hab dies nicht gesehen...
Das war ja ein einfacher und blöder Fehler, welcher mir unterlaufen war. :evil:
Jetzt funktioniert alles und dem PHP Wechsel steht nicht mehr bevor.
Schönes Weekend.
Gruss Jones
Title: Re: [Tutorial] Making additional field searchable
Post by: Jan on April 14, 2008, 12:53:40 PM
Ja, und ohne Deine super Fehlerbeschreibung hätten wir wahrscheinlich noch Wochen gebraucht um ihn zu finden.
Werden den Post als Vorbild für eine perfekte Fehlerbeschreibung bookmarken ;)

Gruß Jan
Title: Re: [Tutorial] Making additional field searchable
Post by: Bob on May 24, 2008, 10:40:33 AM
mhh.. ich bekomms nicht hin :(

Ich hab den PLZ mod: http://www.4homepages.de/forum/index.php?topic=15303.0

und möchte dass man nach plz mitglieder suchen kann hab schon einiges versucht bekomme es aber nicht hin :(

hilft mir da jemand?
Title: Re: [Tutorial] Making additional field searchable
Post by: Bob on May 28, 2008, 04:31:01 PM
keiner?

:(
Title: Re: [Tutorial] Making additional field searchable
Post by: Nicky on June 05, 2008, 12:51:21 PM
hi Bob,

lass mal deine seite sehen..
Title: Re: [Tutorial] Making additional field searchable
Post by: Bob on June 05, 2008, 05:10:53 PM
Seite zeigen geht nich ist vorerst auf Lokalem Linux Rechner muss noch einige Test und Mods einbauen und ne Domain bestellen ;)

Was ich zusätzlich suchbar machen möchte:
Suche nach PLZ
Suche nach Gender
Suche nach Land

ansonsten ist alles was man als suche braucht vorhanden :)

Villt kannst ja ein Paar Tipps geben ;)
Title: Re: [Tutorial] Making additional field searchable
Post by: runway27r on October 15, 2008, 08:11:33 PM
One Problem occured when I installed this MOD and I can't seem to find the problem.

The Radio button appears for the field I added, but not the title of the field.

Look here:

http://www.phlairline.com/apw/search.php

It's the field under all fields. Any pointers where I may have gone wrong?

Thanks
Title: Re: [Tutorial] Making additional field searchable
Post by: Melder on February 05, 2010, 02:09:05 PM
Hallo,

Ich habe auf meiner Homepage nun einige Felder zur Suche hinzugefügt, funktioniert einwandfrei !!

Nun noch eine Frage: Besteht die Möglichkeit, das Radio-Button-Feld so umzubauen, dass man mehrere Felder anwählen kann?
Hier meine aktuelle Suche: http://www.mrn-blaulichter.de/search.php
Auf meiner Seite dann z.B. "Bildname" und "Kennzeichen bzw. Funkrufname"

Gruß Achim
Title: Re: [Tutorial] Making additional field searchable
Post by: mawenzi on February 05, 2010, 02:39:26 PM
@Melder ...

... dies hier ...
... [MOD] Dropdown options for custom database fields : http://www.4homepages.de/forum/index.php?topic=7112.0 ...
Title: Re: [Tutorial] Making additional field searchable
Post by: Melder on February 05, 2010, 06:29:20 PM
Hi,

ich glaube, Du hast mich falsch verstanden, oder ich verstehe den verlinkten MOD nicht!  :oops:
Ich möchte kein Dropdown-Menü, sondern, dass man bei einer Suche ZWEI der "Radio-Buttons" gleichzeitig anwählen kann, sodass die Suche in beiden Feldern durchgeführt wird! z.B. "Fahrgestell" und "Aus-/Aufbauhersteller"!

Vielen Dank für Deine Hilfe
Title: Re: [Tutorial] Making additional field searchable
Post by: Rembrandt on February 05, 2010, 07:47:38 PM
... dass man bei einer Suche ZWEI der "Radio-Buttons" gleichzeitig anwählen kann, ...
bei radio buttons gibt es keine multiple auswahl, die einzige möglichkeit die du hast ist das du unterschiedliche namen vergibst.
<input type="radio" name="search_fields_kennzeichen" value="kennzeichen" /> Nur Kennzeichen bzw. Funkrufname</td>
<input type="radio" name="search_fields_baujahr" value="baujahr" /> Nur Baujahr</td>
<input type="radio" name="search_fields_aufbau" value="aufbau" /> Nur Auf-/Ausbauhersteller</td>
<input type="radio" name="search_fields_fahrgestell" value="fahrgestell" /> Nur Fahrgestell</td>
<input type="radio" name="search_fields_urheber" value="urheber" /> Nur Urheber</td>

nur ob dann noch die suche geht mußt du ausprobieren, b.z.w. müßtest du in der search.php änderungen vornehmen.

wenn du das ganze mit einen optionsfeld machst, könnest du eine multiple auswahl machen.

Title: Re: [Tutorial] Making additional field searchable
Post by: Melder on February 05, 2010, 08:42:30 PM
Also erstmal danke für die Hilfe,

mit den verschiedenen Namen funktioniert die Suche leider nicht mehr richtig, mit einem Optionsfeld kenne ich mich nicht aus und so wichtig, dass ich einen von Euch damit beschäftigen will, ist es nicht! :lol:
Da habe ich andere Baustellen offen 8)

Gruß Achim
Title: Re: [Tutorial] Making additional field searchable
Post by: kubiczek on January 15, 2011, 06:02:24 AM
Hallo,

wie man die image_......  und user_..... Tabele durchsucht ist einfach.

ich versuche aber ein anderes FELD durchsuchbar zu machen.

habe alle schritte schon gemacht

tabele erweitert
ALTER TABLE 4images_wordmatch ADD headline_match TINYINT(1) DEFAULT '0' NOT NULL;

in search_utillitis.php
eingefügt
$search_match_fields = array(
  "image_name" => "name_match",
  "image_description" => "desc_match",
 "image_keywords" => "keys_match",
  "pin_headline" => "headline_match"
  
);

db_field_definition.php

eingefügt
$additional_pin_fields['pin_headline'] = array($lang['pin_headline'], "tinyint", 0);

aber bei der search.php da komme ich nicht weiter

<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: search.php                                           *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7.6                                                *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/

$main_template = 'search';

define('GET_CACHES', 1);
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
include(ROOT_PATH.'includes/search_utils.php');
error_reporting(E_ALL);
$org_search_keywords = $search_keywords;
$org_search_user = $search_user;

if (isset($HTTP_GET_VARS['search_terms']) || isset($HTTP_POST_VARS['search_terms'])) {
  $search_terms = isset($HTTP_POST_VARS['search_terms']) ? $HTTP_POST_VARS['search_terms'] : $HTTP_GET_VARS['search_terms'];
  $search_terms = $search_terms == "all" ? 1 : 0;
}
else {
  $search_terms = 0;
}

if (isset($HTTP_GET_VARS['search_fields']) || isset($HTTP_POST_VARS['search_fields'])) {
  $search_fields = isset($HTTP_POST_VARS['search_fields']) ? trim($HTTP_POST_VARS['search_fields']) : trim($HTTP_GET_VARS['search_fields']);
}
else {
  $search_fields = "all";
}

$search_cat = $cat_id;

$search_id = array();

if ($search_user != "" && $show_result == 1) {
  $search_user = str_replace('*', '%', trim($search_user));
  $sql = "SELECT ".get_user_table_field("", "user_id")."
          FROM ".USERS_TABLE."
          WHERE ".get_user_table_field("", "user_name")." LIKE '$search_user'";
  $result = $site_db->query($sql);
  $search_id['user_ids'] = "";
  if ($result) {
    while ($row = $site_db->fetch_array($result)) {
      $search_id['user_ids'] .= (($search_id['user_ids'] != "") ? ", " : "").$row[$user_table_fields['user_id']];
    }
    $site_db->free_result($result);
  }
}

if ($search_keywords != "" && $show_result == 1) {
  $split_words = prepare_searchwords($search_keywords, true);

  $match_field_sql = ($search_fields != "all" && isset($search_match_fields[$search_fields])) ? "AND m.".$search_match_fields[$search_fields]." = 1" : "";
  $search_word_cache = array();
  for ($i = 0; $i < sizeof($split_words); $i++) {
    if ($split_words[$i] == "and" || $split_words[$i] == "und" || $split_words[$i] == "or" || $split_words[$i] == "oder" || $split_words[$i] == "not") {
      $search_word_cache[$i] = ($search_terms) ? "and" : $split_words[$i];
    }
    else {
      $sql = "SELECT m.image_id
              FROM (".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m)
              WHERE w.word_text LIKE '".addslashes(str_replace("*", "%", $split_words[$i]))."'
              AND m.word_id = w.word_id
              $match_field_sql";
      $result = $site_db->query($sql);
      $search_word_cache[$i] = array();
      while ($row = $site_db->fetch_array($result)) {
        $search_word_cache[$i][$row['image_id']] = 1;
      }
      $site_db->free_result();
    }
  }

  $is_first_word = 1;
  $operator = "or";
  $image_id_list = array();
  for ($i = 0; $i < sizeof($search_word_cache); $i++) {
    if ($search_word_cache[$i] == "and" || $search_word_cache[$i] == "und" || $search_word_cache[$i] == "or" || $search_word_cache[$i] == "oder" || $search_word_cache[$i] == "not") {
      if (!$is_first_word) {
        $operator = $search_word_cache[$i];
      }
    }
    elseif (is_array($search_word_cache[$i])) {
      if ($search_terms) {
        $operator = "and";
      }
      foreach ($search_word_cache[$i] as $key => $val) {
        if ($is_first_word || $operator == "or" || $operator == "oder") {
          $image_id_list[$key] = 1;
        }
        elseif ($operator == "not") {
          unset($image_id_list[$key]);
        }
      }
      if (($operator == "and" || $operator == "und") && !$is_first_word) {
        foreach ($image_id_list as $key => $val) {
          if (!isset($search_word_cache[$i][$key])) {
            unset($image_id_list[$key]);
          }
        }
      }
    }
    $is_first_word = 0;
  }

  $search_id['image_ids'] = "";
  foreach ($image_id_list as $key => $val) {
    $search_id['image_ids'] .= (($search_id['image_ids'] != "") ? ", " : "").$key;
  }
  unset($image_id_list);
}

if ($search_new_images && $show_result == 1) {
  $search_id['search_new_images'] = 1;
}

if ($search_cat && $show_result == 1) {
  $search_id['search_cat'] = $search_cat;
}

if (!empty($search_id)) {
  $site_sess->set_session_var("search_id", serialize($search_id));
}

include(ROOT_PATH.'includes/page_header.php');

$num_rows_all = 0;
if ($show_result == 1) {
  if (empty($search_id)) {
    if (!empty($session_info['search_id'])) {
      $search_id = unserialize($session_info['search_id']);
    } else {
      $search_id = unserialize($site_sess->get_session_var("search_id"));
    }
  }

  $sql_where_query = "";

  if (!empty($search_id['image_ids'])) {
    $sql_where_query .= "AND i.image_id IN (".$search_id['image_ids'].") ";
  }

  if (!empty($search_id['user_ids'])) {
    $sql_where_query .= "AND i.user_id IN (".$search_id['user_ids'].") ";
  }

  if (!empty($search_id['search_new_images']) && $search_id['search_new_images'] == 1) {
    $new_cutoff = time() - 60 * 60 * 24 * $config['new_cutoff'];
    $sql_where_query .= "AND i.image_date >= $new_cutoff ";
  }

  if (!empty($search_id['search_cat']) && $search_id['search_cat'] != 0) {
    $cat_id_sql = 0;
    if (check_permission("auth_viewcat", $search_id['search_cat'])) {
      $sub_cat_ids = get_subcat_ids($search_id['search_cat'], $search_id['search_cat'], $cat_parent_cache);
      $cat_id_sql .= ", ".$search_id['search_cat'];
      if (!empty($sub_cat_ids[$search_id['search_cat']])) {
        foreach ($sub_cat_ids[$search_id['search_cat']] as $val) {
          if (check_permission("auth_viewcat", $val)) {
            $cat_id_sql .= ", ".$val;
          }
        }
      }
    }
    $cat_id_sql = $cat_id_sql !== 0 ? "AND i.cat_id IN ($cat_id_sql)" : "";
  }
  else {
    $cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
    $cat_id_sql = $cat_id_sql !== 0 ? "AND i.cat_id NOT IN (".$cat_id_sql.")" : "";
  }

  if (!empty($sql_where_query)) {
    $sql = "SELECT COUNT(*) AS num_rows_all
            FROM ".IMAGES_TABLE." i
            WHERE i.image_active = 1 $sql_where_query
            $cat_id_sql";
    $row = $site_db->query_firstrow($sql);
    $num_rows_all = $row['num_rows_all'];
  }
}

if (!$num_rows_all && $show_result == 1)  {
  $msg = preg_replace("/".$site_template->start."search_keywords".$site_template->end."/", $search_keywords, $lang['search_no_results']);
}

//-----------------------------------------------------
//--- Show Search Results -----------------------------
//-----------------------------------------------------
if ($num_rows_all && $show_result == 1)  {
  $link_arg = $site_sess->url(ROOT_PATH."search.php?show_result=1");

  include(ROOT_PATH.'includes/paging.php');
  $getpaging = new Paging($page, $perpage, $num_rows_all, $link_arg);
  $offset = $getpaging->get_offset();
  $site_template->register_vars(array(
    "paging" => $getpaging->get_paging(),
    "paging_stats" => $getpaging->get_paging_stats()
  ));

  $imgtable_width = ceil((intval($config['image_table_width'])) / $config['image_cells']);
  if ((substr($config['image_table_width'], -1)) == "%") {
    $imgtable_width .= "%";
  }

  $additional_sql = "";
  if (!empty($additional_image_fields)) {
    foreach ($additional_image_fields as $key => $val) {
      $additional_sql .= ", i.".$key;
    }
  }

  $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
          FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
          WHERE i.image_active = 1
          $sql_where_query
          AND c.cat_id = i.cat_id $cat_id_sql
          ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort']."
          LIMIT $offset, $perpage";
  $result = $site_db->query($sql);

  $thumbnails = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">\n";

  $count = 0;
  $bgcounter = 0;
  while ($image_row = $site_db->fetch_array($result)) {
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $thumbnails .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    $thumbnails .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";
    show_image($image_row, "search");
    $thumbnails .= $site_template->parse_template("thumbnail_bit");
    $thumbnails .= "\n</td>\n";
    $count++;
    if ($count == $config['image_cells']) {
      $thumbnails .= "</tr>\n";
      $count = 0;
    }
  } // end while
  if ($count > 0)  {
    $leftover = ($config['image_cells'] - $count);
    if ($leftover >= 1) {
      for ($i = 0; $i < $leftover; $i++) {
        $thumbnails .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      $thumbnails .= "</tr>\n";
    }
  }
  $thumbnails .= "</table>\n";
  $content = $thumbnails;
  unset($thumbnails);
} // end if
else {
  $site_template->register_vars(array(
    "search_keywords" => format_text(stripslashes($org_search_keywords), 2),
    "search_user" => format_text(stripslashes($org_search_user), 2),
    "lang_search_by_keyword" => $lang['search_by_keyword'],
    "lang_search_by_username" => $lang['search_by_username'],
    "lang_new_images_only" => $lang['new_images_only'],
    "lang_search_terms" => $lang['search_terms'],
    "lang_or" => $lang['or'],
    "lang_and" => $lang['and'],
    "lang_category" => $lang['category'],
    "lang_search_fields" => $lang['search_fields'],
    "lang_all_fields" => $lang['all_fields'],
    "lang_name_only" => $lang['name_only'],
    "lang_description_only" => $lang['description_only'],
    "lang_keywords_only" => $lang['keywords_only'],
    "category_dropdown" => get_category_dropdown($cat_id)
  ));

  if (!empty($additional_image_fields)) {
    $additional_field_array = array();
    foreach ($additional_image_fields as $key => $val) {
      if (isset($lang[$key.'_only'])) {
        $additional_field_array['lang_'.$key.'_only'] = $lang[$key.'_only'];
      }
    }
    if (!empty($additional_field_array)) {
      $site_template->register_vars($additional_field_array);
    }
  }
  $content = $site_template->parse_template("search_form");
}

// [MOD] Slideshow with HIGHSLIDE START

if ($num_rows_all && $show_result == 1)  {
 $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name,  i.image_date, i.image_active, i.image_media_file, i.image_thumb_file".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
          FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
          WHERE i.image_active = 1
          $sql_where_query
          AND c.cat_id = i.cat_id $cat_id_sql
          AND i.cat_id IN (".get_auth_cat_sql("auth_viewimage").")
          AND image_media_file like '%JPG' or '%jpg'
          ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort']."";
  $result = $site_db->query($sql);
  $num_rows = $site_db->get_numrows($result);
  $highslide_js = "";
if ($num_rows) {



$highslide_link = "<p style=\"text-align: center;\">



<a id=\"thumb1\" class='highslide' href='javascript:;' onclick=\"document.getElementById('gallery').onclick(); return false;\"><b>Slideshow<b></a>



</p>";
  $count = 0;
  $bgcounter = 0;
  $slideshow_highslide = "<div class=\"highslide-gallery hidden-container\" bgcolor=\black\">\n";
  while ($image_row = $site_db->fetch_array($result)){
       $slideshow_highslide .= "<a class=\"highslide\" id=\"gallery\" href=\"./".MEDIA_DIR."/".$image_row['cat_id']."/".$image_row['image_media_file']."\" title=\"".$image_row['image_name']."\" onclick=\"return hs.expand(this, miniGalleryOptions1)\"><img src=\"".ROOT_PATH.THUMB_DIR."/".$image_row['cat_id']."/".$image_row['image_media_file']."\"></a>\n";
  }// end while
  $slideshow_highslide .= "</div>";
    $highslide_js .= "\n<script type=\"text/javascript\" src=\"".ROOT_PATH."js/highslide/highslide-full.js\"></script>\n";
    $highslide_js .= "\n<script type=\"text/javascript\" src=\"".ROOT_PATH."js/highslide/highslide_cfg_slide.js\" charset=\"utf-8\"></script>";
    $highslide_js .= "\n<link rel=\"stylesheet\" type=\"text/css\" href=\"".ROOT_PATH."js/highslide/highslide.css\" />\n";
//    $highlslide_js .= "";
  $highslide_js .= "</script>\n";
 }
$site_template->register_vars(array(
  "highslide_link" => $highslide_link,
  "highslide_js" => $highslide_js,
  "slideshow_highslide" => $slideshow_highslide,
  "highslide" => $highslide_js
));
}
// [MOD] Slideshow with HIGHSLIDE END

//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$lang['search']."</span>";

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  "content" => $content,
  "msg" => $msg,
  
  "clickstream" => $clickstream,
  "lang_search" => $lang['search']
));
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');
?>

Die Tabelen Struktur sieht wie auf dem folgendem bild aus

PIN  ----->  pin_headline

(http://www.grosspeterwitz.org/pin.JPG)


an der search.php scheitere ich. Könnte sich das jemand ansehn?

Es wurde auch schon öfters im forum nach Durchsuchbaren Komentar feldern gefragt, man könnte diese erweiterung dann auch dafür verwenden.

gruß



nachtrag

ich habe schon in der search.php

finden

if ($search_user != "" && $show_result == 1) {
  $search_user = str_replace('*', '%', trim($search_user));
  $sql = "SELECT ".get_user_table_field("", "user_id")."
          FROM ".USERS_TABLE."
          WHERE ".get_user_table_field("", "user_name")." LIKE '$search_user'";
  $result = $site_db->query($sql);
  $search_id['user_ids'] = "";
  if ($result) {
    while ($row = $site_db->fetch_array($result)) {
      $search_id['user_ids'] .= (($search_id['user_ids'] != "") ? ", " : "").$row[$user_table_fields['user_id']];
    }
    $site_db->free_result($result);
  }
}

danach einfügen

if ($search_pin != "" && $show_result == 1) {
  $search_pin = str_replace('*', '%', trim($search_pin));
  $sql = "SELECT ".get_pin_table_field("", "pin_id")."
          FROM ".PIN_TABLE."
          WHERE ".get_pin_table_field("", "pin_headline")." LIKE '$search_pin'";
  $result = $site_db->query($sql);
  $search_id['pin_ids'] = "";
  if ($result) {
    while ($row = $site_db->fetch_array($result)) {
      $search_id['pin_ids'] .= (($search_id['pin_ids'] != "") ? ", " : "").$row[$user_table_fields['pin_id']];
    }
    $site_db->free_result($result);
  }
}

und in der global.php
finde
if (isset($HTTP_POST_VARS['search_user']) || isset($HTTP_GET_VARS['search_user'])) {
  $search_user = (isset($HTTP_POST_VARS['search_user'])) ? trim($HTTP_POST_VARS['search_user']) : trim($HTTP_GET_VARS['search_user']);
  if ($search_user != "") {
    $show_result = 1;
  }
}
else {
  $search_user = "";
}

danach einfügen

if (isset($HTTP_POST_VARS['search_pin']) || isset($HTTP_GET_VARS['search_pin'])) {
  $search_pin = (isset($HTTP_POST_VARS['search_pin'])) ? trim($HTTP_POST_VARS['search_pin']) : trim($HTTP_GET_VARS['search_pin']);
  if ($search_pin != "") {
    $show_result = 1;
  }
}
else {
  $search_pin = "";
}

erweitert
Title: Re: [Tutorial] Making additional field searchable
Post by: Rembrandt on January 15, 2011, 06:27:36 AM
werden die werte der "pin" tabelle in die "wordmatch" tabelle eingetragen, nein oder?

das problem ist das dein array "$additional_pin_fields" nirgends ausgelesen wird und in die "wordmatch" tabelle eingetragen wird.
ich würde an deiner stelle versuchen die felder der "4images_pin" tabelle in die "4images_images" tabelle einzutragen, dazu müßtest du den pin mod dahingehend umändern.
dann wäre es ein leichtest die "wordmatch" tabelle mit den werten der pin felder zu füllen.