As Joe wrote in the article about our shiny new blog, he mentioned that we now use Text-Link-Ads for doing advertising on our blog.
Text-Link-Ads provide some adcode for Ruby On Rails applications, but using their code is not as convenient as it could be. Also, I had problems with some parts of it:
It seems that they overwrite a Rails method (request) which meshes up the application until you rename it.
I did some modifications to the adcode so I could use it more easily in the system. Then I extracted the code and created a Rails plugin. This plugin I want to share.
Here a short introduction to use the plugin:
In your Rails app directory run:
script/plugin install http://svn.sparklingstudios.com/misc/rails/plugins/textlinkads/
There isn’t much configuration to do. Copy the text_link_ads.yml file from the example folder to your config folder and replace <<YOUR TLA KEY HERE>> with your XML KEY, which can be found at the Install Ad Code page in your TLA account.
In the controller you want to use TLA include the module and call the text_link_ads method.
Your controller could look like this.
1 class ArticlesController < ApplicationController 2 include TextLinkAds 3 before_filter :text_link_ads 4 5 def index 6 list 7 render :action => :list 8 end 9 10 #... 11 end
The last step is to display the provided links. In the plugin’s example folder is a sample partial which renders the links in a list. You can copy the file _text_link_ads.rhtml to your controller’s view directory and include it in the views everywhere you want to display the ad links by simply rendering the partial:
1 2 <%= render :partial => 'text_link_ads' %> 3
Or you just have a look on how it works and write your own view.
Done.
Now have a look at your site and watch it making some cash for you. :-)
Copyright Notice: I talked to the Text-Link-Ads guys and asked for permission to modify the code and publish it as a Rails plugin.
“There isn’t much configuration to do. Copy the text_link_ads.yml file from the example folder to your config folder and replace <> with your XML KEY, which can be found at the Install Ad Code page in your TLA account.”
Does the key get input like this.
- <>
or – 555555555555555
Do you need the carrots “>>”?
Total newbie question, but I’ve spent a few hours tryin to get there code to work using this plugin and the code. I’m trying to get it to work here: http://www.flippingpad.com/pads/ (right side below partner links)
Do participate!