The Digital Image Archive for The Robin and Lucienne Day Foundation is a great project to work on from the point of view of web development, because from time to time new issues emerge and the system needs add-ons or changes. I have already built a complex search function to cross-reference the academic cataloguing in the Design Archive, but sometimes what’s needed to help office administration is a very straightforward bit of magic! In this case the person in the office needs to look up a particular reference number (called “Archive ID”), or a list of numbers, which they know are in the Archive but can only go to by scrolling through pages of image thumbnail sets.

As an aside; recently I have been enjoying working with Jamie Rumbelow’s MY_model in Codeigniter which helps enormously in cutting down model classes and functions, making it simpler to re-visit systems and add capability. But… and you knew I was going to say this… I wrote the Day Foundation Archive system before diving into MY_model so just had a bit more unravelling to do to remind myself where this widget would fit. It’s always great to see when I’ve progressed my understanding and implementation of my PHP systems and even though I’m kicking myself that I didn’t get into it earlier, Jamie Rumbelows principles – “fat model, slim controller” – give me a working philosophy for this update.

So here’s my plan for a “search for Archive ID” widget in Codeigniter (without Jamie Rumbelow I’m afraid), which can search for an individual ID or comma-separated list of IDs, and return a thumbnail preview as well as a list of invalid IDs, (so that the viewer knows the numbers were received and weren’t just discarded by the system).

My search form is made up of two views which go in Codeigniter’s “views” folder.

The form itself:

The search id form - id_search_form.php

The search id form – id_search_form.php



and the results view:

Search ID results

Search ID results – searchid.php



 

In my controller (welcome.php) I have the searchid() function

In my model class (models/mproducts.php) there are two functions: one to check if an individual ID exists at all (so that I can show any ids that don’t exist as $missing) and one to return each ID’s columns.

A note on the file naming convention for Codeigniter – Class names must have the first letter capitalised with the rest of the name lowercase. When I started working on this application, model filenames could be in lower case, but in more recent versions the filename must match the class name, so also with the first letter capitalised.

The function to check if product id exists. This function will get used within the main function:

Here is the main model function

 

You can find out more about the Robin and Lucienne Day Foundation at their website www.robinandluciennedayfoundation.org. The Archive is not open to the general public, but image loans may be possible for press and research purposes.