Two CodeIgniter libraries I can not live without


I have said it before and I say it again – “Hi, my name is Andreas and I am a CodeIgniter junkie”. I can quit my CodeIgniter (a PHP framework) habit whenever I want, but why would I want to (read Why I fell for CodeIgniter to know more)?

For the last few CodeIgniter projects (begagnadebarnklä – hitta billiga barnkläder for example) I have used two libraries that have made my life as a developer much easier and that I really recommend anyone using CodeIgniter take a serious look at. Those libraries are IgnitedRecord and BackendPro. They are not brand new, but they sure get the work done!

IgnitedRecord is a ORM library that makes interacting with the database so much easier. Especially handling relationships between tables much easier to deal with, an example is getting all posts a user has written in a blog:

$posts = $user->related('posts')->order_by('name', 'desc')->get();

Nice and clean and very easy to setup, all you need to do is to have your models extend IgnitedRecord and then define the relationships in the model. Some other goodies are that it is very easy to make subqueries and nested WHERE statements.

Instead of going in to all the details here I think you should go and download IgnitedRecord straight away and get started, it will save you time.

Almost every project needs some kind of administration backend. With some frameworks (Django) you get this out of the box, not so with CodeIgniter unfourtunatly. BackendPro gives you that and so much more – it also helps out with things like user authentication and access rights, asset management, breadcrumbs, preference handling etc. Only the fact that it is an easy to setup and then handles basic user authentication (such as login, registration and forgotten password) is well worth the price of admission (which is nothing since it is all free). BackendPro also comes with the excellent Matchbox library, which lets you organize your code into modules.

Combining the two
Unfourtunatly the two do not fit perfectly together since BackendPro uses CodeIgniters standard database libraries, so if you need to do any database work with BackendPro itself you need to remember not to use IgnitedRecord. Getting the two libs to play nicely once they are installed is quite straight forward though…

  • Move the ORM() function from system/application/libraries/MY_Loader (a IgnitedRecord file) to system/application/libraries/Loader (a BackendPro file).
  • Delete the MY_Loader file
  • Optionally you could autoload the IgnitedRecord library
  • To make it all work I had to make a file called ignitedrecord.php in system/application/libraries that includes ignitedrecord/ignitedrecord, as per

Do you have any other favorite libraries for CodeIgniter? Please let me and everybody else know in the comments!

Manage many WordPress blogs with one installation


If you are anything like me you have way to many sites to run and maintain, and quite a few of them are probably running on WordPress. The last few versions of WordPress have done wonders when it comes to making it easy to update when a security updates comes out, you just click a button and the rest is taken care of. But if you have many sites and many plugins that also needs updating this can become a full time job, and a very boring full time job at that.

WordPress MU – a bit too limiting
One solution to this is to use WordPress MU which allows you to run many blogs in the same installation. The problem with WordPress MU is that it is quite a hassle to install, and it requires the kind of server access that you won’t have if you run on a standard shared hosting account. Another problem with WordPress MU is that it is usually a few versions behind the regular WordPress, so the latest and greatest (and most secure) features and plugins won’t always work. The WordPress people have stated that moving forward WordPress MU will be one of their areas of focus, so I expect that all the negative stuff I just mentioned will be gone in a year or two, but I want a solution now!

WP-Hive to the rescue
Lately I have started to use the WordPress plugin WP-Hive to solve my multimple WordPressblog problem, and so far it has worked very nicely. Install WordPress and the plugin according to the plugins documentation, it requires some copying of files but otherwise it is pretty much like the standard WordPress install. After you have one blog setup with WP-Hive you can add more blogs to the same WordPress installation, each blog with it’s own domain name and it’s own unique settings. The great thing is that all the blogs you install will share the same basic WordPress installation, the same plugins and the same themes. So you only need to update WordPress or a plugin once and it is updated for all blogs, that is a real time saver. Since WP-Hive is a WordPress plugin you can also use the latest and greatest WordPress verison and all the other plugins that you want.

At the moment I am running some Swedish wedding sites this way, for example Bröllopsinbjudningar, Bröllopsmeny and Bröllopsbukett. They all use the same plugins and the same theme, but all have different settings and different content. With some help from WP Super Cache all my blogs are running nicely from a shared hosting account. The only negative thing I have noticed is that if you have several domains starting with the same letters (“br” in my case) you need to do some manual setup in the database to get things to work.

Do you use something else than WordPress MU or WP-Hive? Tell us all about it!

Click Tracking with jQuery


Generally I use only Google Analytics for the stats of my web apps, but for one of my current projects (Bröllopia – sökmotorn för ditt bröllop – a swedish wedding site) I needed a bit more. I wanted to have detailed statistics for links leading to other sites to use these stats in the app itself. One way of doing this is of course to make all these links go to a page on my site and then when this page loads I record all the stats I want and then redirects to the external site, for example the link loads tracker.php and logs a click on the link with the id “123” (this id needs to be mapped to a link in the database) and then forwards to The link on my site would then look like this:

<a href=''>WebHostNinja</a>

The problems with this is that it is slow (one more page load) and that the link the user sees does not lead to the page, ie the link text “WebHostNinja” and then the user expects the link to be something like “” and nothing else. I don’t like this from a usability point of view. Not that I have any evidence for it, but I suspect that relevant outgoing links help the sites Google juice. Definitly it helps the Page Rank of the site I link to, and why should I not help them?

My solution is to use some jQuery magic. Download and install jQuery (btw, if you like jQuery, then take a look at the fantastic jQuery tools). Then add the class “track_this_link” to each link tag that you want to track as well as give each link tag an unique id (so you can track which link is which). The href attribute should point to the external site directly and not to some internal page. The link above would now look like this:

<a href='' id='123' class='track_this_link'>WebHostNinja</a>

Next step is to add a some javascript that adds an onClick event to all the links with the class “external_link”:

$('a.track_this_link').click(function() {
$.post(, {});
return true;

This means that each time an external link is clicked a post request is sent to with a unique id for the link in question. What is left is to implement the tracker.php script so that it can handle the post and save the data you are interested in to the database in a secure and correct way. I am happy to just summarize the number of clicks per link on a daily basis, but if you want to save detailed data for each click.

Do you have a better solution to this problem? Let me know! 10 years old


Today, it is exactly 10 years since I bought the domain It was September 13th 1999 when I registered the domain, before that I was a domain virigin. For most of the time it has been a really bad web site to market my consulting skills, that it was bad didn’t really matter since I had employment for most of the time anyway. For years the only reason I kept the domain was to have my own private email address and not use my work email or hotmail for my private stuff (yes, this was BEFORE GMail, it was that long ago).

There have been versions in Swedish, Spanish and English (even a breif French one) depending on where in the world I were at any given moment and the designs have varied quite a lot, as you can see below. A few years ago I started blogging and since then has been a perfectly OK blog. Here’s a look back at old designs…

1999 – 2002
Not much to say… it was one of my first web pages and I have learned a lot since then. At least I didn’t have a spinning @ sign or any applets on the page!

Digitalistic 1999-2002

2002 – early 2006
Here’s the Spanish version of the second generation of I still use the logo from back then, even if the colours have changed (thanks Kemie for the great logo!). 2003-2006

2006 – early 2008
Then the blogging started…

Digitalistic 2006-2008

(Both Pownce and Popfly that I had invites to back then are not dead – RIP Pownce!)

2008 – 20??
You are looking at it! (or if you are reading the RSS feed, you could be looking at

I have no plans to let go and it will be my main domain for quite some time. It will be cool to see how it develops during the next 10 years (assuming we still use domains in 10 years that is).

The 3 biggest trends in Digital Media right now


A week ago I got an email from a student of Digital Media at Hyper Island in Karlskrona, Sweden. She wanted to ask me several questions for one of her projects, and I hope that the answers I sent was somewhat userfull. One of the questions were “What are the biggest trends in digital media right now? and what’s coming?”, and after thinking about that one a bit I came up with this rambling answer…

  • The culture of digital natives are starting to invade the mainstream. That means that content that are currently on youtube and other similar sites are soon going to be much more available for the general public. Fiction made for the web (webisodes etc) are going to start competing with old school media (TV series and cinema movies). We are yet to see the first mainstream hit, but there have been a couple of underground hits already (Dr Horrible for example). It has for many years now been possible to cheaply produce quality media by a small team or by yourself from your house, and soon we are going to see the big effects of this.
  • Worldwide increased bandwidth and connectivity. In the western part of the world this means more bandwidth, in large parts of Africa/Asia this means that people get online via mobile devices in ever increasing numbers. This will probably affect the media and services available in two ways.  First of all increased bandwidth is going to push ever more rich experiences onto the web in a more efficient and broadly available manner. Some years down the line this means the death of TV as we know it today as well as many many bad experiments with new GUIs as developers and designers are trying to figure out what to do with all this new bandwidth. That people in the 3rd world are going online also means that web services that are simple and usefull will have a great potential, services that are usefull to farmers in the Indian countryside but not to European urban youngsters.
  • The (somewhat) success of the Kindle and the digitalization of books is just a first step towards the death of the printed book as we know it – at least the current printed book business model, not the actual physical existence of a printed book. Already 3 industries (software, music, movie) have tried to fight the new technology to keep old business models alive, and they have all failed. You can try to stop “evil” new techology (like the VHS, or the Pirate Bay), but unless you change with it you will loose. The book industry have to decide what to do when books starts to be ever copyable pieces of content (just as music is today). The old business model where publishers print paper editions of books will die, the question is how the industry deals with this. The early signs is that they are trying to fight the new technology instead of accepting and using it, and that is a bad sign for the publishers.

As you noticed I didnt mention trends like the end of the newspaper industry as we know it or mashups or anything like that, I do think that the trends above do have a bigger impact and/or are more interesting.

What do you think? Did I get things somewhat right or completely wrong?