Mangoblog plugin: Adsense. Ads on your blog! v1.1.1

January 15, 2010: Updated the contents of this blog post, because of version 1.1!
Version 1.1.1: added a warning about the adsense maximum of 3 ads on one page.

For mangoBlog, I created a new plugin called Adsense. The name is actually a bit misleading, since you can use any ad service, as long as you only need to put some html/javascript on the page to have the banners displayed.

What it does is pretty simple: it displays advertisements on your weblog. On my own blog here, you can see them above this full post, and inbetween the excerpts on the index and archive pages.

Plugin settings page screenshotOptions

There are 2 configuration options besides adding the adsense code itself.

One is "On which iterations should the advertisements be shown?". This setting is usefull when you want to show ads inbetween some of the blog excerpts, but not all.
A value of "1,3,5" will show ads on the first, third, and fifth time the plugin is called.
You can leave this setting empty, so it will display ads on every call.
Note: this setting is not used for the event 'After a full blog post', because that event does not have iterations.

The other is "Show where". For now, there are 2 choices:

  • "after a full blog post". When choosing this, the ads will be shown underneath a full blog post (on the /post.cfm page).
  • "when the custom event 'showAdsense' is called". You will have to edit your templates (skin) for it; more info can be read underneath.

How to install

First, you need to add the plugin. Go to mangoBlog admin > Plugins > Add the following url: http://www.railodeveloper.com/adsense-plugin-mangoblog/adsense-plugin-mangoblog-v1.1.1.zip

Now click on the 'Activate' link next to the plugin 'adsense 1.1.1'. A message will appear to configure the plugin.

Off course you need to create the adsense code at http://adsense.google.com/, and then you can add it to the settings page.

Creating extra places for the adsense code to show up

By default, the ads will only be shown after a full blog post.
If you want to show the ads on other pages and/or places as well, then you need to paste the following code into your template(s):

<mango:Event name="showAdsense" />

I pasted it into archives.cfm and index.cfm, just before the tag "</mango:Post>". And in post.cfm (this page) just after "<div id="content">".

The template files can be found in [your website root]/skins/[your template name]/

Styling

The ads are surrounded with a div with class "adsensecode": <div class='adsensecode'>...your ad ...</div>
So you can use standard css to add borders, margins, etc.

The code

If you're using it, or have a question, let me know by leaving a comment!

del.icio.us Digg StumbleUpon Facebook Technorati Fav reddit Google Bookmarks
| Viewed 6043 times

No comments yet.

(will not be published)
Leave this field empty