FAP CUSTOMIZATION - FAP Search Multiple Fields


Subject: FAP CUSTOMIZATION - FAP Search Multiple Fields
I've been looking for a way to do this for awhile now. Searched many phpbb boards and mightygordon boards.

Current search system has a drop down box to search either username, picture title or description. I'd like to perform a search and return results for all those fields at once (well probably not username, but at least title and description). I'm not a php expert but can stumble my way around. I tried a few different things (mainly hard coding a search function) but I can't get it to search more than one field without erroring out with a "Bad Request" message.

Any ideas on how to implement this? Can't imagine it would be too intensive. Thanks in advance for any ideas anybody can give me in the right direction.

Profile PM  
Subject: Re: FAP Search Multiple Fields
dilirum wrote: [View Post]
I've been looking for a way to do this for awhile now. Searched many phpbb boards and mightygordon boards.

Current search system has a drop down box to search either username, picture title or description. I'd like to perform a search and return results for all those fields at once (well probably not username, but at least title and description). I'm not a php expert but can stumble my way around. I tried a few different things (mainly hard coding a search function) but I can't get it to search more than one field without erroring out with a "Bad Request" message.

Any ideas on how to implement this? Can't imagine it would be too intensive. Thanks in advance for any ideas anybody can give me in the right direction.

At the moment I have no time...

I'll try to do it when I have some free time... but maybe Lefty or Artie will have a play too. :mri:

Subject: Re: FAP Search Multiple Fields
Thanks for the reply.

Anyone?

Profile PM  
Subject: Re: FAP Search Multiple Fields
Main reason i'm looking for this is to search from outside phpBB. I want to have an HTML form where users can enter a keyword then use a drop down box to search "album, forum, etc." including other pages on my site. But I really don't want it to be "album description, album title, forum, etc." Just too many options there. Want to keep it simple and use search album to automatically search both fields.

Anybody have any idea on how to get the search function to search both fields?

Profile PM  
Subject: Re: FAP Search Multiple Fields
I gues you could have a try modifying album_search.php in some way like this...

Code: [Download] [Hide]
  1. AND (p.pic_desc LIKE '%" . $s . "%' OR p.pic_title LIKE '%" . $s . "%' OR p.pic_username LIKE '%" . $s . "%') 


Have a try and let me know...

Subject: Re: FAP Search Multiple Fields
Gorgon,

Thanks for the help but I'm really not sure where to put that. I'm not that great with PHP, just basically stumble my way around. Sorry.

I played with my album_search.php but it doesn't seem to work anyplace I try to insert tha, but again, I'm not sure of what I'm doing.

Profile PM  
Subject: Re: FAP Search Multiple Fields
This may get you close to what you're lookin for.

Code: [Download] [Hide] [Select]

#
## ---- [ OPEN ] -------------------------------------------------------------------------------------------
#
includes/page_header.php
#
## ---- [ FIND ] ----------------------------------------------------------------------------------------------
#
'L_DESCRIPTION' => $lang['Description'],
#
## ---- [ AFTER ADD ] ------------
#
'L_TITLE_DESCRIPTION' => $lang['Title_Description'],

#
## ---- [ OPEN ] ------------------------------------------------------------------------------------------
#
language/lang_english/lang_main.php
#
## ---- [ FIND ] ------------
#
$lang['Description'] = 'Description';
#
## ---- [ AFTER ADD ] -----------------------------------------------------------------------------------
#
$lang['Title_Description'] = 'Title & Description';

#
## ---- [ OPEN ] ------------
#
album_search.php
#
## ---- [ FIND ] -------------------------------------------------------------------------------------------
#
if ($m == 'user')
{
$where = 'p.pic_username';
}
elseif ($m == 'name')
{
$where = 'p.pic_title';
}
elseif ($m == 'desc')
{
$where = 'p.pic_desc';
}
else
{
message_die(GENERAL_ERROR, 'Bad request');
}
#
## ---- [ REPLACE WITH ] ----------------------------------------------------------------------------------------
#
if ($m == 'user')
{
$where = "AND p.pic_username LIKE '%" . $s . "%'";
}
elseif ($m == 'name')
{
$where = "AND p.pic_title LIKE '%" . $s . "%'";
}
elseif ($m == 'desc')
{
$where = "AND p.pic_desc LIKE '%" . $s . "%'";
}
elseif ($m == 'title_desc')
{
$where = "AND (p.pic_desc LIKE '%" . $s . "%' OR p.pic_title LIKE '%" . $s . "%')";
}
else
{
message_die(GENERAL_ERROR, 'Bad request');
}
#
## ---- [ FIND ] -------------------------------------------------------------------------------------------------------------
#
$count_sql = "SELECT COUNT(pic_id) AS count
FROM " . ALBUM_TABLE . ' AS p,' . ALBUM_CAT_TABLE . " AS c
WHERE p.pic_approval = 1
AND " . $where . " LIKE '%" . $s . "%'
" . $search_pg . "
AND p.pic_cat_id = c.cat_id";
#
## ---- [ REPLACE WITH ] ---------------------------------------------------------------------------------------------------
#
$count_sql = "SELECT COUNT(pic_id) AS count
FROM " . ALBUM_TABLE . ' AS p,' . ALBUM_CAT_TABLE . " AS c
WHERE p.pic_approval = 1
" . $where . $search_pg . "
AND p.pic_cat_id = c.cat_id";
#
## ---- [ FIND ] ------------------------------------------------------------------------------------------------------------------
#
$sql = "SELECT p.pic_id, p.pic_title, p.pic_desc, p.pic_user_id, p.pic_username, p.pic_time, p.pic_cat_id, p.pic_approval, c.cat_id, c.cat_title, c.cat_user_id
FROM " . ALBUM_TABLE . ' AS p,' . ALBUM_CAT_TABLE . " AS c
WHERE p.pic_approval = 1
AND " . $where . " LIKE '%" . $s . "%'
AND p.pic_cat_id = c.cat_id
" . $search_pg . "
ORDER BY p.pic_time DESC LIMIT ".$limit_sql."";
#
## ---- [ REPLACE WITH ] ---------------------------------------------------------------------------------------------------------------
#
$sql = "SELECT p.pic_id, p.pic_title, p.pic_desc, p.pic_user_id, p.pic_username, p.pic_time, p.pic_cat_id, p.pic_approval, c.cat_id, c.cat_title, c.cat_user_id
FROM " . ALBUM_TABLE . ' AS p,' . ALBUM_CAT_TABLE . " AS c
WHERE p.pic_approval = 1
" . $where . "
AND p.pic_cat_id = c.cat_id
" . $search_pg . "
ORDER BY p.pic_time DESC LIMIT ".$limit_sql."";

#
## ---- [ OPEN ] ------------
# (each of these 8 template files)
templates/subSilver/album_cat_body.tpl
templates/subSilver/album_comment_body.tpl
templates/subSilver/album_index_body.tpl
templates/subSilver/album_memberlist_body.tpl
templates/subSilver/album_personal_body.tpl
templates/subSilver/album_personal_index_body.tpl
templates/subSilver/album_search_body.tpl
templates/subSilver/album_showpage_body.tpl
#
## ---- [ FIND] ------------
#
<option value="desc">{L_DESCRIPTION}</option>
#
## ---- [ AFTER ADD ] -----------------------------------------------------------------------
#
<option value="title_desc">{L_TITLE_DESCRIPTION}</option>
#
## ---- [ SAVE FILES ] ------------------------------------------------------------------------
# Eom



Profile PM  
Subject: Re: FAP Search Multiple Fields
Artie, That friggin rocks! It works like a champ! I was beginning to think that it might be too complicated to conjure something up, but here you come and just bust it out like it's nuthin!

Thanks Artie! You rock! I owe ya' one! :mryellow:

Profile PM  
Subject: Re: FAP Search Multiple Fields
dilirum wrote: [View Post]
.... but here you come and just bust it out like it's nuthin!

Would be nuthin for MG, but for me it requires some effort :icy_lol_flag:

Anyway, you are welcome. :wink:

Profile PM  
Subject: Re: FAP Search Multiple Fields
Artie wrote: [View Post]
Would be nuthin for MG, but for me it requires some effort :icy_lol_flag:

Anyway, you are welcome. :wink:

It requires some effort for me as well... :wink:

Anyway... added to standard FAP. :wink:

Thanks.


Page 1 of 1


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Generation Time: 0.0904s (PHP: 22% SQL: 78%)
SQL queries: 10 - Debug Off - GZIP Enabled