View Full Version : How to implement "search" on a custom page?
veenuisthebest
08-01-2008, 06:00 PM
Hii.. just check out this custom vb page (http://tech6.com/links/).
As you can see, the page lists websites with some details on the left side. There is a Category field displayed too.
All I want is to enable search within that page by Category that looks something like this
https://vborg.vbsupport.ru/attachment.php?attachmentid=84905&d=1217617098
where Add On Releases listbox can be replaced with my Categories list.
Need help on how to do so.
Thank You
Lynne
08-01-2008, 06:12 PM
Just copy the form from the regular quick search. make sure all those variables are there and then add your own (for categories).
veenuisthebest
08-01-2008, 07:01 PM
well.. sry but I have no idea how to do this.. can you please explain me in more detail.
This is the quick search form i got in the navbar:-
<!-- header quick search form -->
<div class="vbmenu_popup" id="navbar_search_menu" style="display:none" align="$stylevar[left]">
<table cellpadding="4" cellspacing="1" border="0">
<tr>
<td class="thead">$vbphrase[search_forums]</td>
</tr>
<tr>
<td class="vbmenu_option" title="nohilite">
<form action="search.php?do=process" method="post">
<input type="hidden" name="do" value="process" />
<input type="hidden" name="quicksearch" value="1" />
<input type="hidden" name="childforums" value="1" />
<input type="hidden" name="exactname" value="1" />
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<div><input type="text" class="bginput" name="query" size="25" tabindex="1001" /><input type="submit" class="button" value="$vbphrase[go]" tabindex="1004" /></div>
<div style="margin-top:$stylevar[cellpadding]px">
<label for="rb_nb_sp0"><input type="radio" name="showposts" value="0" id="rb_nb_sp0" tabindex="1002" checked="checked" />$vbphrase[show_threads]</label>
<label for="rb_nb_sp1"><input type="radio" name="showposts" value="1" id="rb_nb_sp1" tabindex="1003" />$vbphrase[show_posts]</label>
</div>
</form>
</td>
</tr>
<if condition="$vboptions[threadtagging]">
<tr>
<td class="vbmenu_option"><a href="tags.php$session[sessionurl_q]" rel="nofollow">$vbphrase[tag_search]</a></td>
</tr>
</if>
<tr>
<td class="vbmenu_option"><a href="search.php$session[sessionurl_q]" accesskey="4" rel="nofollow">$vbphrase[advanced_search]</a></td>
</tr>
$template_hook[navbar_search_menu]
</table>
</div>
<!-- / header quick search form -->
I put this in my template, it displays a search form, what next ? how to make it search from websites table by category ?
--------------- Added 1217623494 at 1217623494 ---------------
well this code gives me the correct search layout that I want, but what to do next ?
<form action="forumdisplay.php" method="get">
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="f" value="$forumid" />
<input type="hidden" name="page" value="$pagenumber" />
<input type="hidden" name="pp" value="$perpage" />
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="thead"><phrase 1="$limitlower" 2="$limitupper" 3="$totalthreads">$vbphrase[showing_threads_x_to_y_of_z]</phrase></td>
</tr>
<tr valign="top">
<td class="alt1">
<table cellpadding="3" cellspacing="0" border="0" align="center">
<tr>
<td><select name="sort" id="sel_sort">
<option value="category" $sort[title]>Category</option>
<option value="reviews" $sort[postusername]>Reviews</option>
</select></td>
<td><select name="order" id="sel_order">
<option value="asc" $order[asc]>Ascending</option>
<option value="desc" $order[desc]>Descending</option>
</select></td>
<td class="smallfont" align="$stylevar[right]" style="padding-top:$stylevar[cellpadding]px">
<input type="submit" class="button" value="Show Websites" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<form action="inlinemod.php?forumid=$forumid" method="post" id="inlinemodform">
<input type="hidden" name="url" value="$url" />
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="forumid" value="$forumid" />
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center" id="threadslist">
<tbody>
</tr>
</tbody>
</form>
</table>
Lynne
08-01-2008, 08:17 PM
You want to show all the categories? Just copy the code that makes the Forum Jump menu on the bottom of the left side of the page. Put that code in your page and make it spit out the drop-down like it does for the jump menu.
veenuisthebest
08-01-2008, 08:44 PM
1. Can you please explain me programmatically ?
2. I had already done what you had said, copied the code to my page template->the form shows->made a drop down of that->now what ?
3. Can this be done with the original vbulletin SEARCH.PHP file in form's action ? If yes, how will I make it retrieve search data from my custom tables that my page is storing data in.
See the demo of what i am doing here (http://www.vinayaks.com/testvb/links.php).
Thank you
Lynne
08-01-2008, 09:21 PM
You added the code from the search field into a new form after the form you had there (the one with the drop-down and Show Websites). You kinda have the html all messed up around there. You only need one form - you have two (one that you can't even access). You need to add those "type=hidden" inputs to under your other hidden inputs. You also need to give your new form a unique name..... I have a search form on my torrents page and I have it set to only search thread titles in two forums. This is some of what I added in my template:
<form action="search.php" method="post" name="vbform">
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="do" value="process" />
<input type="hidden" name="titleonly" value="1" />
<input type="hidden" name="showposts" value="0">
<input type="hidden" name="sortby" value="lastpost">
<input type="hidden" name="order" value="descending">
<input type="hidden" name="s" value="">
<input type="hidden" name="forumchoice[]" value="12">
<input type="hidden" name="forumchoice[]" value="13">
All my input fields that they may select
</form>So, you can see that I do use the search.php action and I give it a unique name. I also fill in a ton of hidden fields that the search form will need. Then, all my input fields use the correct name to correspond to what the search.php file wants.
veenuisthebest
08-01-2008, 09:52 PM
alright.. I have edited it now.. plz see it (http://www.vinayaks.com/testvb/links.php)
So, here's my form now !
<!-- Modified Website Search Layout -->
<form action="search.php" method="post" name="linksearch">
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="do" value="process" />
<input type="hidden" name="titleonly" value="1" />
<input type="hidden" name="showposts" value="0">
<input type="hidden" name="sortby" value="lastpost">
<input type="hidden" name="order" value="descending">
<input type="hidden" name="s" value="">
<input type="hidden" name="forumchoice[]" value="12">
<input type="hidden" name="forumchoice[]" value="13">
<input type="hidden" name="page" value="$pagenumber" />
<input type="hidden" name="pp" value="$perpage" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="thead"><phrase 1="$limitlower" 2="$limitupper" 3="$totalthreads">$vbphrase[showing_threads_x_to_y_of_z]</phrase></td>
</tr>
<tr valign="top">
<td class="alt1">
<table cellpadding="3" cellspacing="0" border="0" align="center">
<tr>
<td><select name="category" id="category">
<option value="0">Category</option>
<option value="1">Arts and Literature</option>
<option value="2">Blogs and Personal</option>
</select></td>
<td><select name="order" id="sel_order">
<option value="asc" $order[asc]>Ascending</option>
<option value="desc" $order[desc]>Descending</option>
</select></td>
<td class="smallfont" align="$stylevar[right]" style="padding-top:$stylevar[cellpadding]px">
<input type="submit" class="button" value="Show Websites" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<!-- /Modified Website Search Layout -->
Now, what to do next ? How would search.php would make a search in my custom table ?
Thanks
Lynne
08-01-2008, 11:37 PM
I would copy the search.php page, call it something else (sorry, I thought you want to use the vb search) and change the queries in there to go to your table. You can then probably get rid of some of the hidden fields (the two "forumchoice[]" ones in mine were to just search those two forumids on my page).
veenuisthebest
08-02-2008, 12:10 AM
isn't there any other way ? SEARCH.PHP is a 121kb file, there's so much in it that is not at all required.
Can't I keep it simple something like links.php?do=search , it would be more efficient i think.
thanks
Lynne
08-02-2008, 12:16 AM
Actually, I realized that you can still use the search.php page. Just set up another do action for your form - like do=links or do=directory. That should work out fine.
veenuisthebest
08-02-2008, 12:34 AM
please explain more.. how to setup another form action ?? and how will it work out fine ??
I have my own page called links.php, it has its own tables, queries, variables and everything.
I am trying all the possible ways but cannot get it to work. I think it would be best if I get it to work by doing something like links.php?do=search , I did it the same way for reviews (links.php?do=review), but can't get search working this way. This way all the functions of the directory would remain in a single file.
--------------- Added 1217641186 at 1217641186 ---------------
see we already have the search form ready in links.php
This is my links.php?do=search part of the file:-
//*********SEARCH PAGE************
if ($_REQUEST['do'] == 'search')
{
//WHAT TO PUT IN HERE?
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('links_searchbits') . '");');
$db->free_result($query_Search);
}
//*********END SEARCH PAGE************
--------------- Added 1217646411 at 1217646411 ---------------
alright, things are done !... :up:
I did a sub-page links.php?do=search and it works fine.
Thanks
--------------- Added 1217653087 at 1217653087 ---------------
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.