Monday, October 22, 2012

The Things About Stuff

Editing with the editor to do some editing at is a real adventure.  I could go on about this all day probably, but today we'll keep it simple and take a look at just one bit of fun; inserting an ad.

Let's start with a simple blog post.  We'll add a title, a little text, and some minor formatting...

The preview on this looks great!  This blog is going to be insanely popular, I can tell already!

Wait, I know...  I'll insert an ad at the bottom.  Why, with all the page views this will get, I can go home early!

Now, one way to do this is in's options.  In there one can link up a Google adsense account, add ads to the blog's layout, and optionally opt for ads to appear between each post.  Oh sure, that's one way...  But suppose a chimp wants more control over ad usage and type?  For example, Google will render only three ad units per page.  So, if someone looks at the main blog page, they will only see three ad units, even though ads may be selected to appear between all posts.  You don't really get to pick which posts get the ads in this case. 

It's also nice to mix up the ad types, and placement manually.  And to not have ads in some posts.  In general, we know a thoughtful chimp is all about ad control on this here internet.

That said, there's nothing to stop you from getting some ad script from the adsense website and pasting it into your post.  First, switch the editor to HTML mode.  Here's what the post looks like.

Google's blogger loves the div tag!

But anyway, this is fine, no problem, it'll work.

Next you go get your adsense ad source, and copy and paste it, in HTML mode so you get the raw Java script.

Here's the result.

The ad is pasted at the end of the post body.  Can't you can just feel the revenue!  But wait...

Switch back to Compose mode and take a look.

What the chimp is that!?
Switch back to the HTML mode, quick!

Well, isn't that fun...  The editor has altered the script and changed "//-->" to "-->".  It took out the forward slashes and changed and greater-than sign, which we entered in HTML mode, manually, just moments before, to a gt literal.


Isn't it great when tools decide what you wanted to type when you espressly typed something else, in a specific mode, provided just for typing that sort of thing?

Clearly the script will not work and this sorry state, and you don't get an ad.  No ad, no early retirement.  Boooo!

The solution?  There isn't one.  The blogger editor will change that code everytime you switch from HTML mode to compose mode.  What you have to do here, is make sure you don't give it that chance.  Paste your ad code last, in HTML mode, and hit publish, from HTML mode.

And have a nice day.