Replace Drupal Search Box with Google Adsense Custom Search Module in Drupal 6 + Zen Theme


Drupal search doesn't work well with International language and after a couple years of using it, I decided to try Google Adsense Custom Search Engine. Well, at first, I would like to try just Google Custom Search Engine (CSE) but after reading from a few webpages, they said that both of them are the same. Google CSE will generate regular advertising while Google Adsense CSE will generate advertising that will share some revenue with the website owner. So, why use Google CSE if Google Adsense CSE can do the same while you may get some revenue. (Even it's just a little)

So, I downloaded Google Adsense 6.x-1.3 module, installed Google Adsense CSE module that come with Google Adsense. Then, replaced Seach box in Zen Theme. My original Zen - page.tpl.php is below :

page.tpl.php - Original

          <?php if ($search_box): ?>
            <div id="search-box">
              <?php print $search_box; ?>
            </div> <!-- /#search-box -->
          <?php endif; ?>

Just replace the code, the final code will look like below :

page.tpl.php - With Adsense CSE

          <?php if ($search_box): ?>
            <div id="search-box">
             <?php $block = module_invoke('adsense_cse', 'block', 'view', 0); ?>
             <?php print $block['content']; ?>
            </div> <!-- /#search-box -->
          <?php endif; ?>

That's it. Now, your search box on the top right corner will be replaced by Google Adsense CSE.

Software Tested :
- Drupal 6.20
- Zen 6.x-1.1 Theme
- Google Adsense 6.x-1.3 Module

Source :


Thanks this worked perfectly

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.