TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 06:45:40 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,106
  • Total Topics: 21,213
  • Online today: 358
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 193
  • Total: 193

forum/google search block

Started by extacy, February 27, 2006, 11:32:35 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

extacy

May need to be moved, sorry....

I have been trying to come up with a search block that does exactly what the one on smf home page does. 1, sends you to a google site search and 2 sends you to a forum search. This is the best I can do with my limited knowledge of html/php etc. You just add this to a script box and change the 2 mysites.com to your own and you should be in business...

***You may need to change the "/forum" so it matches your forums location...***

<table border="0" cellspacing="1" style="border-collapse: collapse" width="13%" id="table1" height="105">
<tr>
<td align="left"><tbody><tr><th class="right" align="left">
<p style="margin-top: 0; margin-bottom: 0"><b><font color="#FF0000">Site Search</font></b></th></tr>
<tr>
<td class="right" align="left" valign="top" height="95">
<form style="margin-top: 4px; margin-bottom: 4px;" method="get" name="searchform" action="http://www.google.com/search" target="_top">
<input name="sitesearch" value="www.mysite.com" type="hidden">
<p style="margin-top: 0; margin-bottom: 0">
<input alt="search" style="width: 65px;height:22" name="as_q" size="20" type="text"> <input style="width: 41; font-weight: bold; height:26" value="GO" type="submit">
</p>
</form>

<p style="margin-top: 0; margin-bottom: 0"><b><font color="#FF0000">Forum Search</font></b></p>

<form action="http://www.mysite.com/forum/index.php?action=search2" method="post" target="_top" style="margin-top: 4px; margin-bottom: 4px;" method="get" name="searchform">
<p style="margin-top: 0; margin-bottom: 0">
<input name="search" style="width: 65px;height:22" name="as_q" size="20" type="text"> <input style="width: 42; font-weight: bold; height:26" value="GO" type="submit">
</p>
</form></td>
</tr>
</table>




I'm told it can be done easier with php, but me's don't know how.....

Anyone care to take a stab at it.....


Thanks
X





Mitch

Just out of curiousity what is the difference of this and the actual search function?

Besides you can go to google.

extacy

Well it searches your forum normally or a google site search.
As the 2 turn out way different results.

The real stupid thing about it is if you go to google adsence and get the code for adding a google site search and your site has not been indexed a whole lot by google,you will be lucky if you get 1 page of results. However if you do it the way laid out here you will get about 10 pages of results and you get credit with google adwords ($) for them doing the search.

The whole thing started out as we were tiring to get the same search as www.simplemachines.com w/ the pull down box and asked around on several forums for help with it. with not much help.... So we came up with our own jerry-rigged version of it..... Because everytime someone searches smf and forgets to pull down the tab to "community" they (smf) get paid from google..... and that's what we are really trying to do with this thing....... However they may be some problems with the way it interacts with adsence.... 


A subject that really should be looked into by the coding gurus as it can help all smf forum owners offset cost.....

I'm told smf does theirs with php...?. :uglystupid2:

thanks
X


eldacar

Here's mine:
Put this in a file called search.php
<?php

// Search redirector

if ($_REQUEST['where'] == 'entire') {
header('Location: http://www.google.com/search?domains=somedomain.com&sitesearch=somedomain.com&q=' $_REQUEST['q']);
} else {
header('Location: http://somedomain.com/index.php?action=search2;search=' $_REQUEST['q']);
}

?>
And change your TPortalBlocks.template.php search function to:// TPortal searchblock
function TPortal_searchbox()
{
    global $context, $settings, $options, $txt , $scripturl;

echo '<form action="http://somedomain.com/search.php" method="post" style="text-align: center; margin: 0; margin-bottom: 3px;">
<input type="text" name="q" value="" style="width: 85%;" /><br />
<select id="where" name="where" style="width: 42%; margin-top: 2px;" >
<option value="entire">Entire Site</option>
<option value="forum" selected="selected">Forum</option>
</select>
<button type="submit" style="width: 42%; font-size: 85%;">', $txt[182], '</button>
</form>';

}
You can also add other places, I added an option to search my site's wiki.

extacy

#4
Hey thanks, I will look at it as soon as I awake... ;)

TwinsX2Dad

Quote from: eldacar on March 20, 2006, 09:42:49 AM
Here's mine:
Put this in a file called search.php........

Now that is good - cleaner than the one I created. Now I have an extra something else to do.   ;D

ontap

i wont ever be using a search box by google! nooooooo way  :tickedoff:

Crip

OnTap!
you just plain don't like Google do ya.. hehehe :)
I have become comfortably numb!

Cripzone | Crip's Free 2.0.2 Themes



TwinsX2Dad

Quote from: OnTap! on March 20, 2006, 05:07:19 PM
i wont ever be using a search box by google! nooooooo way  :tickedoff:

But Google is your friend........ Google is your friend........ Google is your friend........ Google is your friend........ Google is your friend........

Do you hear the utopian tone in that?

I now am seeing Logan's Run flashbacks.......   :coolsmiley:

extacy

QuoteHere's mine:
Put this in a file called search.php

<?php

// Search redirector

if ($_REQUEST['where'] == 'entire') {
header('Location: http://www.google.com/search?domains=somedomain.com&sitesearch=somedomain.com&q=' $_REQUEST['q']);
} else {
header('Location: http://somedomain.com/index.php?action=search2;search=' $_REQUEST['q']);
}

?>



Hey,
This really looks great except 1 tiny problem.. No matter where i put this in my search.php it crashes when you do the forum search...

I replaced all the somedomain.com with ours etc...

The google part seems to work fine... I thought perhaps you might want us to make a new search.php with only this in it and i got the same results...   (crash)  Is there somehwere specific we need to put this code in our search.php or is there something else I'm missing?..  :uglystupid2:

This is exactly what I was looking for!!! THX ;)