vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How to implement "search" on a custom page? (https://vborg.vbsupport.ru/showthread.php?t=186970)

veenuisthebest 08-01-2008 06:00 PM

How to implement "search" on a custom page?
 
1 Attachment(s)
Hii.. just check out this custom vb page.

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/attachmen...5&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:-

HTML Code:

<!-- 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>
                &nbsp;
                <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 [DATE]1217623494[/DATE] at [TIME]1217623494[/TIME] ---------------

well this code gives me the correct search layout that I want, but what to do next ?


HTML Code:

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

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:

HTML Code:

<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

So, here's my form now !

HTML Code:

<!-- 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.


All times are GMT. The time now is 12:11 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01271 seconds
  • Memory Usage 1,821KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_html_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete