Author Topic: [Tutorial] Making additional field searchable  (Read 178991 times)

0 Members and 1 Guest are viewing this topic.

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Re: [Tutorial] Making additional field searchable
« Reply #30 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
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: [Tutorial] Making additional field searchable
« Reply #31 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?

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Re: [Tutorial] Making additional field searchable
« Reply #32 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
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: [Tutorial] Making additional field searchable
« Reply #33 on: April 28, 2005, 05:43:57 PM »
Can you post the code? That would be great!! 




Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Re: [Tutorial] Making additional field searchable
« Reply #34 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
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: [Tutorial] Making additional field searchable
« Reply #35 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?

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Re: [Tutorial] Making additional field searchable
« Reply #36 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'";
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: [Tutorial] Making additional field searchable
« Reply #37 on: April 29, 2005, 04:53:37 PM »
Thank you Jan!
Once more... great support.   :D

Serge

Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Re: [Tutorial] Making additional field searchable
« Reply #38 on: May 01, 2005, 02:01:01 AM »
hi can we search by user_gender in the user gender table?

Offline Sopur

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
    • Bilder des Harassenlaufs in Basel
Re: [Tutorial] Making additional field searchable
« Reply #39 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

Offline WhiteRabbit

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: [Tutorial] Making additional field searchable
« Reply #40 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.

Offline WhiteRabbit

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: [Tutorial] Making additional field searchable
« Reply #41 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.

Offline hinzwiekunz

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
    • http://www.hinzwiekunz.de
Re: [Tutorial] Making additional field searchable
« Reply #42 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.

Offline hinzwiekunz

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
    • http://www.hinzwiekunz.de
Re: [Tutorial] Making additional field searchable
« Reply #43 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

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Re: [Tutorial] Making additional field searchable
« Reply #44 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.
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search