4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
February 19, 2018, 12:59:13 PM

Login with username, password and session length
Search:     Advanced search
Check the new Tutorial subforum with helpfull guides and tutorials for modifications and tweaks.
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Modifications / Modifikationen
| |-+  Mods & Plugins (Releases & Support)
| | |-+  Tutorials (Moderators: mawenzi, Rembrandt)
| | | |-+  [Tutorial] Making additional field searchable
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: «« « 1 2 [3] 4 5 » »» Print
This topic has not yet been rated!
Author Topic: [Tutorial] Making additional field searchable  (Read 139132 times)
Jan
Administrator
4images Guru
*****
Offline Offline

Posts: 5024

Thank You
-Given: 0
-Receive: 27


View Profile WWW
« 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
Logged

Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search
TIMT
Hero Member
*****
Offline Offline

Posts: 505

Thank You
-Given: 0
-Receive: 0


View Profile
« 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?
Logged
Jan
Administrator
4images Guru
*****
Offline Offline

Posts: 5024

Thank You
-Given: 0
-Receive: 27


View Profile WWW
« 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
Logged

Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search
TIMT
Hero Member
*****
Offline Offline

Posts: 505

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #33 on: April 28, 2005, 05:43:57 PM »

Can you post the code? That would be great!! 



Logged
Jan
Administrator
4images Guru
*****
Offline Offline

Posts: 5024

Thank You
-Given: 0
-Receive: 27


View Profile WWW
« Reply #34 on: April 29, 2005, 02:02:38 PM »

The easiest way is to replace

1
WHERE ".get_user_table_field("", "user_name")." LIKE '$search_user'";

with

1
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
Logged

Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search
TIMT
Hero Member
*****
Offline Offline

Posts: 505

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #35 on: April 29, 2005, 03:35:24 PM »

I have the mentioned line replaced with the following code :

1
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?
Logged
Jan
Administrator
4images Guru
*****
Offline Offline

Posts: 5024

Thank You
-Given: 0
-Receive: 27


View Profile WWW
« Reply #36 on: April 29, 2005, 04:33:24 PM »

Nothing, i did it wrong Wink

Use:

1
WHERE ".get_user_table_field("", "user_name")." LIKE '$search_user' OR user_vorname LIKE '$search_user' OR  user_name2 LIKE '$search_user'";
Logged

Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search
TIMT
Hero Member
*****
Offline Offline

Posts: 505

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #37 on: April 29, 2005, 04:53:37 PM »

Thank you Jan!
Once more... great support.   Very Happy

Serge
Logged
ascanio
Hero Member
*****
Offline Offline

Posts: 569

Thank You
-Given: 0
-Receive: 3


View Profile WWW
« Reply #38 on: May 01, 2005, 02:01:01 AM »

hi can we search by user_gender in the user gender table?
Logged
Sopur
Jr. Member
**
Offline Offline

Posts: 54

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« 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
Logged
WhiteRabbit
Newbie
*
Offline Offline

Posts: 29

Thank You
-Given: 0
-Receive: 0


View Profile
« 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...):

1
2
3
4
          <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.
Logged
WhiteRabbit
Newbie
*
Offline Offline

Posts: 29

Thank You
-Given: 0
-Receive: 0


View Profile
« 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.
Logged
hinzwiekunz
Jr. Member
**
Offline Offline

Posts: 80

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« 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  [Expand]
1. Create a new column in the table 4images_wordmatch called photographer_match
1
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  [Expand]
2.  Open includes/search_utils.php and find this part...

My Code is like this:
1
2
3
4
5
6
$search_match_fields = array(
  "image_name" => "name_match",
  "image_description" => "desc_match",
  "image_keywords" => "keys_match",
  "image_license" => "license_match"
);

Quote  [Expand]
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  [Expand]
4. Open the template search_form.html and add this:
1
<input type="radio" name="search_fields" value="image_photographer" /> {lang_image_photographer_only}

1
2
3
4
5
6
7
8
<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...
1
value="1"{image_license_yes}
, but nothing has changed.

1
[b]5.[/b] Rebuild the search index.
Done.
Logged
hinzwiekunz
Jr. Member
**
Offline Offline

Posts: 80

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #43 on: August 31, 2005, 07:33:36 AM »

Could there anybody give me a hint?  Crying or Very sad
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
Logged
Jan
Administrator
4images Guru
*****
Offline Offline

Posts: 5024

Thank You
-Given: 0
-Receive: 27


View Profile WWW
« 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:

1
<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.
Logged

Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search
Pages: «« « 1 2 [3] 4 5 » »» Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.042 seconds with 20 queries.
Post your comments here