Adding Google Custom Search on MyBB

posted Jul 5, 2011, 2:41 AM by magic stone
1. Create your Adsense search unit. Follow the wizard until you come across the following screenies.

Choose "Open results within my site"
Put the following URL in the box: "http://example.com/forums/results.php"
Continue following the wizard. Save the unit. You shall a page like this:

2. Enter the Adsense "Search Box Code" anywhere you want in the template. e.g. i've put it in the Sidebox on this site.

3. Create a new template called "adsenseresults"(without quotes) in the AdminCP and put the following codes in it. Enter your Adsense "Search Results Code" in it.

<html>
<head>
<title>{$mybb->settings['bbname']} - Results</title>
{$headerinclude}
</head>
<body>
{$header}

<- Enter the adsense "Search Results Code" here ->

{$footer}

4. Create a file called "results.php" and add the contents below in it. Upload the file to your server to where you specified in step 1 i.e. example.com/forums/results.php

<?php

define
('IN_MYBB'1);

require 
"./global.php";
global 
$mybb;

add_breadcrumb("Results""results.php");

eval(
"\$adsenseresults = \"".$templates->get("adsenseresults")."\";"); 

output_page($adsenseresults); 

?>

5. You're done
Comments