I really need help in inserting GoogleAds and Blogads in my pages.

As y'all know, they're both JAVASCRIPT based. For the Blogads (since they are columnar) I created a block and cut and pasted the javascript. This did not work at all --Drupal just spewed the code back on the page.

Am assuming the same will happen with my horizontal GoogleAds. You can see them at http://www.culturekitchen.com (Yeah, go ahead and visit our sponsors as your form of contribution :)

Would the banner module work for the Google ads?

Thanks!

Comments

sepeck’s picture

Check out this site/
http://www.adsensed.com/google-adsense-blog/

I know this has been occassionally touched on in some posts in the past month, so you might try some forum searches.

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

blogdiva@www.culturekitchen.net’s picture

I did do a search but found nothing useful.
I'll definitely give a looky at your source.

Thanks!

/liza sabater
http://www.culturekitchen.com
http://www.culturekitchen.net

JGarrison’s picture

Put the adsense script inside of a PHP echo statement like this:

<?php
echo "put adsense script here";
?>

Be sure to escape the quotes inside the google javascript with a \
For example, the first line should look like this:

<... type=\"text/javascript\"><!--

-Jim
http://www.dietandhealthinfo.com

blogdiva@www.culturekitchen.net’s picture

I think this is EXACTLY what I needed it.

Fantastic!
Thanks!

liza sabater
http://www.culturekitchen.com
http://www.culturekitchen.net

jasonwhat’s picture

could you give a full example of how your script looked after this was done? I've been curious about using java in blocks or in the links menu to create rollover dropdown menus and your example may be a good starting point.

Steven’s picture

In Drupal 4.5 you don't need the echo statement. Just put the literal code in, but as a PHP block. This will prevent any HTML from being stripped.

JGarrison’s picture

Cool - that works.

I tried inserting the google code as HTML and when that didn't work I thought I was being clever entering the code as PHP enclosed in the echo statement. But I just tried it with the echo statement and it works like a charm.

Good to know since sometimes I run across a cool piece of javascript I'd like to use.

Thanks.
-Jim
http://www.dietandhealthinfo.com

jasonwhat’s picture

Steve says you don't need the echo statement. Who is right? I'm trying to create a rollover menu and neither example works for me.

oNyx’s picture

When in doubt... just try one way... see if it works and if not... look at the generated source code in your browser. This way you can easily see what happened to that piece of code.

If everything fails you can create your own module, which generates such a block. Just take the block_example.module and modify it a bit.

jasonwhat’s picture

I tried both ways and didn't get it working. Obviously, it has for other people, which method did they use? Could someone post their whole code somewhere as an example or email me throught the contact module, since Drupal won't allow the javascript?
jasonwhat (at) gmail.com

Anybody use this for rollover menus?

daniel read’s picture

Using PHP echo as suggested worked great for me. Nothing else I tried would. I set the block type to PHP, and I also had to escape the quote characters as suggested by JGarrison. An additional tip for those trying to get this to work: be careful with line breaks. I had to mess around with putting line breaks in different places. I'm not sure exactly what I did to make it work. When I got something that worked, I stopped messing with it. I tried pasting in an example, but Drupal is stopping me from posting it because the embedded script is identified as suspicious (which is a nice feature).

HTH,
Dan

---------------------------------------------------------------
The developer.* Cooperative Digest
http://www.developerdotstar.com/community