When building a custom backend, quite often a client will ask for the ablilty to order records/posts/images…
Here’s a tried and tested method i use to build this functionality. It will work with or without js. In this example we will order the traditional post records.
Create a table to hold your posts and include a column (int) called order.
Each time a new post is saved, the order column is assigned the auto inc value of the rows id. This prevents records from ever having the same order value.
To provide the user with a way to order posts records, i’ll start with the HTML. This process is designed to degrade gracefully when JS is disabled. Dont worry if this process seems a bit clunky to the user, chances are they’ll have js turned on. I have found by restricting yourself to develop for HTML first created better structured and semantic code. Quite often divining straight in there with the javascript will get the job done, but it’ll be a headache to maintain. Read the rest of this entry »
Tags: CMS, Code, CodeIgniter, notifications
Posted in Code, CodeIgniter, PHP
Often, I find I need to send notifications to the user (webpage) during server code. This may be a warning, notification, or a message that an action has hapend. If you’re using a MVC framework it’s not practical to exit running code or echo out the message. From a User Interface perspective it is also imperative that the user knows where to look for these notifications and what they mean. Read the rest of this entry »
Tags: Code, CodeIgniter, shortie, urls
Posted in Code, CodeIgniter, PHP, Uncategorized
Recently I needed code to shorten URLS and tweet said url as a twitter update. This all needed to happen in their existing CMS built using Codeigniter.
Turns out the twitter part was easy, thanks to simonmaddox’s nice twitter CI library. I got a few whiffs of a url shortening CI library around the web, but it looks like the code was no longer available. Oh well, a good excuse to knock up a new library!