UBB.Dev
Posted By: Gizmo [7.x] Google Custom (Adsense) Search - 08/23/2009 9:34 PM
VNC Web Design UBB.Google Custom (Adsense) Search by Gizmo (James at VNC Web Design; http://www.virtualnightclub.net/)
This addon allows your users to search Google and have the results display inline on your forum.

Homepage: http://www.virtualnightclub.net/detail/4/ubb-gsearch.php
Support: https://www.ubbdev.com/forums/ubbthreads.php/topics/318145/7_x_Google_Adsense_Search.html

Install Instructions:
Upload the included files to your server (be careful to preserve directory structure) and add a link
to the header.inc.php template file.


Setup:
Be sure to edit the language file (languages/english/google.php), this file contains the configuration options for this script; including your publisher ID which contains your style code ID. This is a requirement as it includes your URL, Publisher ID, Style ID; basicaly everything this script needs.

There is an "advanced" tick in the Script file (/scripts/google.inc.php), basically just affecting how the title is built; for most users this won't need to be adjusted.


Mods:
To add an option in your header:
In /templates/default/header.tpl Find:
Code
<a href="{ubb url="ubb=faq"}">{$lang.FAQ_TEXT}</a>

Add ABOVE:
Code
<a href="{ubb url="ubb=google"}">{$lang.GOOGLE}</a>    

In /languages/english/generic.php Find:
Code
$ubbt_lang['FAQ_TEXT'] = "FAQ";

Add AFTER:
Code
$ubbt_lang['GOOGLE'] = "Google";


To have "Using the Google Search" display on the Who's Online:
In /languages/english/online.php Add:
Code
$ubbt_lang['GOOGLE'] = "Using the Google Search";

Files:
/languages/english/google.php
/scripts/google.inc.php
/templates/default/google.tpl

Attached File
Posted By: Gizmo Re: [7.x] Google Custom (Adsense) Search - 08/23/2009 10:04 PM
Extended the instructions with possible modifications people will request ("How do I add to the Who's Online Page?" and "How do I add to my Header?")
Posted By: badfrog Re: [7.x] Google Custom (Adsense) Search - 08/23/2009 10:20 PM
trying it out now!

what would it take to add it to the search drop down menu?

and this still doesn't resolve my original problem, redirecting a google search from another page and having the output in the wrapper..

I have custom error pages, so when someone gets an error 404, they get a window offering them helpful advice, like site navigation, and a search box.. that search box currently has to point to a standalone page to display googles results, I can't get in the wrapper...
Posted By: badfrog Re: [7.x] Google Custom (Adsense) Search - 08/23/2009 10:32 PM
ok, I just removed the google search box from my 404 page and put a link in its place to the the google mod..
not as fancy, but should work just as well.
Posted By: Gizmo Re: [7.x] Google Custom (Adsense) Search - 08/23/2009 10:50 PM
Adding it to the search dropdown shouldn't be difficult at all, simply open the header.tpl file and then locate the search dropdown code:
Code
{if $search_link}
<div id="search_popup" style="display: none">
<form method="post" action="{ubb url=""}">
<input type="hidden" name="ubb" value="dosearch" />
<input type="hidden" name="daterange" value="0" />
<input type="hidden" name="where" value="bodysub" />
<input type="hidden" name="fromsearch" value="1" />
<input type="hidden" name="checkwords" value="1" />

<table class="popup_menu">
<tr>
<td nowrap='nowrap' class="popup_menu_header">{$lang.SEARCH_HEADER}</td>
</tr>
<tr>
<td class="popup_menu_content noclose">
<label>
<input type="text" name="Words" class="form-input" />
<input type="submit" name="textsearch" value="{$lang.GO_BUTTON}" class="form-button" />
</label>
</td>
</tr>
<tr>
<td class="popup_menu_content"><a href="{ubb url="ubb=search"}">{$lang.ADVANCED_BUTTON}</a></td>
</tr>
</table>
</form>
</div>
<script type="text/javascript">
registerPopup("search_popup");
</script>
{/if}

Then, add a new line after:
Code
			<tr>
<td class="popup_menu_content"><a href="{ubb url="ubb=search"}">{$lang.ADVANCED_BUTTON}</a></td>
</tr>

Like:
Code
			<tr>
<td class="popup_menu_content"><a href="{ubb url="ubb=google"}">Google Search</a></td>
</tr>
Posted By: Gizmo Re: [7.x] Google Custom (Adsense) Search - 08/23/2009 10:52 PM
As for your 404 stuff, theres an additional parameter you have to pass (it makes it so the search result stuff only shows when a search is being preformed); so you'd put:

Code
<form action="/forum/ubbthreads.php" id="cse-search-box">
<input type="hidden" name="ubb" value="google" />
<input type="hidden" name="process" value="1" />
<input type="hidden" name="cx" value="partner-pub-5168900358893374:runafbk50ac" />
<input type="hidden" name="cof" value="FORID:11" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="text" name="q" size="31" class="form-input" />
<input type="submit" name="sa" value="Search" class="form-button" />
</form>
Posted By: badfrog Re: [7.x] Google Custom (Adsense) Search - 08/24/2009 12:06 AM
it parses, brings up the mod on the site, but I get..
Code

Google
Error


Not Found
The requested URL /cse?ubb=google&process=1&cx=partner-partner-pub-1428978494316705%3Ayix18h-jgii&cof=FORID%3A11&ie=UTF-8&q=test&sa=Search&ad=w9&num=10&rurl=http%3A%2F%2Fwww.vannin.com%2Fthreads%2Fubbthreads.php%3Fubb%3Dgoogle%26process%3D1%26cx%3Dpartner-partner-pub-1428978494316705%253Ayix18h-jgii%26cof%3DFORID%253A11%26ie%3DUTF-8%26q%3Dtest%26sa%3DSearch was not found on this server.
Posted By: Gizmo Re: [7.x] Google Custom (Adsense) Search - 08/24/2009 12:24 AM
Odd URL... Could you link me to a page that's returning that as a result so i can check it out?
Posted By: badfrog Re: [7.x] Google Custom (Adsense) Search - 08/24/2009 12:49 AM
just trigger a 404 error on my site...

Posted By: Gizmo Re: [7.x] Google Custom (Adsense) Search - 08/24/2009 1:18 AM
Wow, thats interesting lol... I'll take a look later on tonight (working on another mod :ahem:)
Posted By: badfrog Re: [7.x] Google Custom (Adsense) Search - 08/24/2009 1:40 AM
another mod? what could that be?! lol

fixing this now is more of a curiosity for me than a necessity.

having the text input box on the 404 page looks better to me.. personal preference I guess.

for now I can just use a link to the the embedded search page since I know that works.

Posted By: Gizmo Re: [7.x] Google Custom (Adsense) Search - 08/24/2009 1:49 AM
well, the 404 is on google's site; it doesn't like how they pull the fake url into the mix and that's what it's choking on.

I finished v1 of the nag screns.
Posted By: badfrog Re: [7.x] Google Custom (Adsense) Search - 08/24/2009 2:18 AM
thanx for the work on the nag screens, will test it out a little later.
© UBB.Developers