We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27424
    • 18 Posts
    Just a simple NOT WORKING snippet for Adsense. It is taken from the Google Analitycs snippet.

    Instead of regClientStartupScript what should I use?

    /*
     * 	Name:	GoogleAdsense
     *	Author:	Written by Denis Rasia - 1 Jun 2006
     *	Desc:	Add adsense to your webpage.
     *
     *  Set inside width the width of your Ad, and in height the (doh) height
     *  Check Google Adsense Page for more info about the correct sizes to use
     *	Usage:	[[GoogleAdsense?account='pub-0000000000000000000']]
     */
    
    $account = isset($account)? $account: '';
    $width = '728';
    $height = '90';
    
    
    if(!empty($account)) {
    	$modx->regClientStartupScript('
    	<script type="text/javascript"><!--
    google_ad_client = '.$account.';
    google_ad_width = '.$width.';
    google_ad_height = '.$height.';
    google_ad_format = "'.$width.'x'.$height.'_as";
    google_ad_type = "text_image";
    google_ad_channel ="";
    google_color_border = "333333";
    google_color_link = "C94093";
    google_color_bg = "FFFFFF";
    google_color_text = "333333";
    google_color_url = "6C82B5";
    //--></script>
    <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>');
    }
    
      who dares win
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      It might work if you use two regClientStartupScript calls, one for the first set of <script... tags, the the other for the second.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 9191
        • 20 Posts
        Do the scripts really have to be in the startup code? Can’t you just echo them, or even use a chunk?
          • 27424
          • 18 Posts
          no, it doesn’t have to be at the start...

          maybe yes, it’s better to use a chunk (sorry, I am really new to modx)
            who dares win
            • 6726
            • 7,075 Posts
            Interresting idea, an adsense snippet, too bad I can’t help you with the code but keep going at it, I am pretty sure this will raise interrest !
              .: COO - Commerce Guys - Community Driven Innovation :.


              MODx est l&#39;outil id
              • 2762
              • 1,198 Posts
              I’m using adsense for a lot of sites, and I’ve used a lot of adsense modules/script for many other cms.
              Now my little opinion is there are too much things to set adsense with a snippet :
              google_ad_client = '.$account.';
              google_ad_width = '.$width.';
              google_ad_height = '.$height.';
              google_ad_format = "'.$width.'x'.$height.'_as";
              google_ad_type = "text_image";
              google_ad_channel ="";
              google_color_border = "333333";
              google_color_link = "C94093";
              google_color_bg = "FFFFFF";
              google_color_text = "333333";
              google_color_url = "6C82B5";


              I use chunks (naming adsense 468x60 adsense 120x240) and TV for front/backend, and works great to change size of adsense banner or switch with other banners.

              a better solution should be a module to set default parameters (account code, channel..) and a preview grin for different size of banners...something like EPG gallery module.


              ....but it’s only a dream ’cause i’m not a coder laugh grin
                Free MODx Graphic resources and Templates www.tattoocms.it
                -----------------------------------------------------

                MODx IT  www.modx.it
                -----------------------------------------------------

                bubuna.com - Web & Multimedia Design