Posts

Quick Function: Inserting ads into your RSS feeds in WordPress

On my main wordpress site (this one your reading now), I like to display a single line below each RSS feed item that tells people quickly about some of my other sites.

The ad appears like this:

The code for it is pretty straight forward, and can also be used to display a copyright message linking to your site, or anything along those lines. Place the following code in your theme’s functions.php file:


function insertAds($content) {
  if(is_feed()) {
    srand((float) microtime() * 10000000);
    $banners = array();
    $banners[] = 'Banner number 1. <a href="http://www.somerandomsite/" target="_blank">Some more banner text</a>';
    $banners[] = 'Banner number 2. <a href="http://www.somerandomsite/" target="_blank">Some more banner text</a>';
    $banners[] = 'Banner number 3. <a href="http://www.somerandomsite/" target="_blank">Some more banner text</a>';
    $banners[] = 'Banner number 4. <a href="http://www.somerandomsite/" target="_blank">Some more banner text</a>';
    $rn = array_rand($banners);
    $content = $content.'
<hr />'.$banners[$rn];
  }
  return $content;
}
add_filter('the_excerpt_rss', 'insertAds');
add_filter('the_content', 'insertAds');

You could also replace this with banner images. Anyway, what this does is randomly select which text to display on your rss feed items. So for each article, you could have a different ad appearing.

If you wanted to use this to display only one message (like a copyright), you’d use this version:


function insertMsg($content) {
  if(is_feed()) {
    $banner = 'You are reading my blog. <a href="http://www.linktoblog/" target="_blank">Name of your blog</a>';
    $content = $content.'
<hr />'.$banner;
  }
  return $content;
}
add_filter('the_excerpt_rss', 'insertMsg');
add_filter('the_content', 'insertMsg');

That’s it, like I said, it’s a quick function, but it serves it’s purpose.

SMS Notifications: A feature returns to DBStract

For some of you who may remember, there was a feature a few years ago on DBStract that let people receive notifications on their cell phones when new entries were made to their tables.

The method used was one where you entered your phone number, and provider and it would send you an SMS-email message. It worked but it wasn’t a method I was happy with, and eventually removed it.

Thanks to Twilio.com and their SMS gateway, we’ve now integrated a new solution to receiving SMS notifications.

When you create or edit a table, you now have the option to select to received text messages when someone fills out a form on your site (or where ever you’ve placed a form).

This works well for people on the go who still want to get notified when someone fills out a form, either for a support request, article submission, events, you name it.

This is also the first of several new updates DBStract will be receiving in the new little while, which I’m pretty happy about.

W3Reminder.com: website in 2 days

This week, as part of the twilio.com SMS contest, I decided to quickly whip up a reminder service that would send your phone a text when you told it to.

Even without the contest, I would have done it anyway, but it just provided a good incentive to do it now.

Once you sign up, you have two ways of setting reminders, either from your account, or from your phone by sending a text message in the appropriate format.

There’s still a little work to do, but it’s been sending me proper reminders for a couple days so that works for me :)

Some spring cleaning

This week I’ve been making a few changes around the blog from a new design to a new overall post structure.

There’s still some work to go on it so please bare with me for a couple of days :)

Project Piece is for sale

I have listed my Project Piece site for sale on Flippa. The listing is here, bidding is open for one month, and the buyout is $250.

For Sale on Flippa.com: Project Piece

New Wordpress plugin: YQL Auto Tagger

I like Dan’s Open Calais Auto Tagger plugin, but I found Open Calais wasn’t always quite returning the results I wanted when I used their service for specific sites.

YQL lets you send content and returns tags and they’ve been relatively relevant to the post, so I forked Dan’s plugin (with his permission of course), and modified it to use YQL instead of Open Calais, the end result was this small plugin.

With the YQL Auto Tagger plugin, you’ll never have to think of tags for your posts again. The plugin uses the Yahoo Query Language to perform semantic analysis of your post text and suggest tags for you. Add them to your post with just a click.

Based on the Open Calais Auto Tagger by Dan Grossman – http://www.dangrossman.info

download files

Quick Function: small PHP function to add canonical URLs to each page

When I redid Foodizu a few months ago, I added canonical URLs to each page. The easiest to do this was with a quick PHP function:


<?php
function canonical_link(){
   $url = 'http';
   if ($_SERVER["HTTPS"] == "on") {$url .= "s";}
   $url .= "://";
   if ($_SERVER["SERVER_PORT"] != "80") {
      $url .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"];
   } else {
      $url .= $_SERVER["SERVER_NAME"];
   }
   if( isset($_SERVER['REQUEST_URI']) ){
      $url = $url . $_SERVER['REQUEST_URI'];
   }
   if($url){
      echo '
<link rel="canonical" href="'.$url.'" />'."\n";
   }
}
?>

to call this function you simply add in your header somewhere:


<?php canonical_link(); ?>

and it will display the canonical URL.

Playing with new tools

We have a compaq mini CQ10 floating around the office so I decided to try out some of the new OSes that are out there for netbooks.

Currently, I run Windows 7 on my main netbook, so I wanted to see how Ubuntu and Chromium run with it.

I made the decision early on to complete remove windows XP from the netbook, and use Ubuntu Netbook Remix as the main OS. Installation went pretty smoothly, and the only hitch was getting the wifi drivers to work, which really didn’t take much to fix.

Once you install UNR, make sure you go to System > Update Manager and update all. If it says there are no updates, go to “Settings”, and make sure you check the top 4 options under the “Ubuntu Software” tab. Once the updates are done, go to System > Hardware Manager, and your wifi card should show up.

I also installed Chromium on another partition. Chromium is the Open source release of Google’s ChromeOS, and so far it’s been nice to play with, but I’m not sure I’d use it as a main OS due to how long it takes for the wifi to start up (upwards of 10 minutes after you reboot). Also, while most of my work is done in the cloud, it’s nice to be able to unplug sometimes.

Also, being the avid ebook reader that I am, I made use of Wine and install the Kindle for PC application which runs pretty smoothly after you tell wine to run as windows 98.

Back to Top