User account menu

  • Log in
BXTra.net

Breadcrumb

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

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

By BXTra | 7:56 PM PST, Fri February 18, 2011
Drupal

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 :
- http://drupal.org/node/26502

About text formats
  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.

munyiva

12 years 9 months ago

Permalink

Thanks

Thanks this worked perfectly
  • Reply
  • Add new comment

  • Will the router get the Openvpn as a client option?
    6 years ago
  • cancellation
    6 years 1 month ago
  • Router ASUS RT-N12 D1 tomatoes passwort falsch
    7 years 8 months ago
  • WPS button = 30/30/30 hard reset button
    7 years 9 months ago
  • Save my day!
    8 years 3 months ago
  • How to
    8 years 6 months ago
  • Can i still access my modem (the one with the ISP provided)?
    8 years 6 months ago
  • A saving step!
    8 years 10 months ago
  • Problem with Asus n12e-c1
    8 years 11 months ago
  • don't use Hostgator
    9 years 2 months ago

© 2007 - 2023 BXTra.net. All Rights Reserved. 
Certain other content, photos and artwork displayed on BXTra.net are protected by copyright and are the property of their respective owners.

Privacy Policy