Adding AdSense search engine to your site

Ramui webblog script has no inbuilt site search module. So you have to add an external site search script to your site. There are many high quality search scripts are available on the internet today. In between them I select Google AdSense search engine. The advantages of such a module are,

  1. It is free of cost;
  2. Easy setup. You can generate search engine code within a few minutes;
  3. Very easy to integrate with your site;
  4. You can earn few dollars by the pay per click ads comes with it.

Adsense search template

First of all you have to remember that if you want to display search result within your site you need a space of min. width 800px. So you have to design such a template. I design a search template which is based on the default template. Please download this template; extract the zip file and upload it to your /fw_blog/templates/ folder.

Download search template

Create your search engine

To get Adsense search module code login to your Adsense control panel. If you do not have a Google AdSense account please click here to register it for free. After signing in click on the "Get Ads" link under the tab "AdSense Setup". A list of Adsense product will appear on the screen. Choose the link "AdSense for Search".
A search engine setup wizard will appear which will guide you to generate your search engine code. Here is a quick guide to fill up that setup form.

1.Search Type:Only sites I select
2.Selected sites:Your site URL.
3.Optional Keywords:Keep blank.
4.Site language:English.
5.Your site encoding:West European Latin-1 (ISO-8859-1).
6.Country or territory for Google domain:Your country of residence.
7.Opening of search results page:Select option "Open results within my own site"
type URL of your search page (http://yourdomain.com/search.html).
8.Name Your Search Engine:Write a name of your choise.

After submitting that setup form you will get two sets of code; one is for search box which you will add at the top of your template file, and another (search result code) is for displaying the search result on your search page. You have to add that code at the content part of your search.html page. Save those codes in a text file and logout from your Adsense account. Your next step is to create a new web page search.html.

  1. Login to your website control panel;
  2. Click on the "Post-> Create new" link;
  3. Insert the search result code at the content part of the page.
  4. Insert the following line of code in the header field of the page.
    <?php $fw_pagestyle='search'; ?>
  5. Save and publish that page.

Now you have to add "search box" code into your default web template file such that search box appears at the top of the all pages. Here I show how to add code in your "simple" template file.

1. Create an add-on page "searchbox" and put the search box code in it.
2. Now open the file Edit template->simple->index.php for editing.

3. Find the following lines of code (from 35 to 38).

Code | Download
else{echo '<div style="padding: 22px 0; font-size: 20px; font-weight:600;">'.strtoupper($fw_site_array['sitename']);}
?>
</div></div>
<?php

4. Replace those lines by the following lines of code.

Code | Download
else{echo '<div style="padding: 22px 0 0 0; font-size: 20px; font-weight:600;float:left;clear:left;">'.strtoupper($fw_site_array['sitename']);}
echo '</div>';
$searchbox=$fw_db->get_addon("searchbox");
if(!empty($searchbox)){echo '<div style="padding: 26px 0 0 0; float:right;clear:right;">'.$searchbox['content'].'</div>';}
echo '</div>';

Alternatively you can download following attachment and replace it with /fw_blog/templates/simple/index.php file.

index.php