Tags
Rate this article
0
  • email Email to a friend
  • print Print version
  • Plain text Plain text
Browsing: Home » How-Tos

Google AdSense for Mobile

If you have a mobile website on which you'd like to display Google ads, this How-To should help you to use AdSense PHP integration code.

If you're new to Google AdSense for Mobile, you shoud refer to step-by-step setup guide that will lead you through the process of implementing ads on your mobile webpage: https://www.google.com/adsense/support/bin/answer.py?hl=en-au&answer=75763

AdSense for Mobile does not utilize JavaScript integration code, therefore you cannot simply paste it inside templates. To use the AdSense for Mobile with your Vivvo website, you need to use their PHP integration code (you will choose that in Step 5 on your AdSense setup) and do the following:

Find this PHP code snippet in AdSense code integration:

$google_ad_handle = @fopen(google_get_ad_url(), 'r');
     if ($google_ad_handle) {
       while (!feof($google_ad_handle)) {
         $ads .= fread($google_ad_handle, 8192);
       }
fclose($google_ad_handle); 

and change it to look like this:

function get_my_ads(){
     $ads = '';
     $google_ad_handle = @fopen(google_get_ad_url(), 'r');
     if ($google_ad_handle) {
       while (!feof($google_ad_handle)) {
         $ads .= fread($google_ad_handle, 8192);
       }
       fclose($google_ad_handle);

     }
     return $ads;
}

After this, you include that file where you stored your AdSense code at a beginning of your index.php file (or copy entire PHP integration at the top of index.php).

Finally, after this line (around line 40 in index.php file):

 $template =& $sm->get_template();  

place the following line: 

 $template->assign('ADS', get_my_ads());  


And that is all. Now you should be able to access your Ads by including the {ADS} VTE tag for AdSense in any template you like:

  <vte:value select=”{ADS}” />

 

See Also:
Mobile/PDA plug-in

Comments (0 posted):

You must be registered member of Vivvo.net to post a comment.