TWIG templating engine for PHP

Recently I’ve been using the TWIG php templating engine for a large project. I hadn’t used a dedicated php templating engine since Smarty and had persuaded myself that they were pretty much redundant of the needs of creating sites and apps these days since, perhaps with the advent of websites becoming so front-end-heavy, most ‘web-designers’ are savvy and knowledgeable enough to understand where php tags start and end.

However with a work spec. suggesting the use of one I tried it and I’m pleasantly surprised, and have decided that perhaps with something like TWIG in the stack adding some nice shorthand here and there there’s definitely a place for it.

I’ll leave you to find out more, I just felt like singing it’s praises slightly! As the twig documenation will tell you, it’s fast, secure and flexible.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

/* TWIG code snippet proof of concept.
Some comments left in so you can see alternative use/syntax
- rob ganly */


// $twigEnginePath = '/Applications/MAMP/bin/php5/lib/php/Twig/';
$twigEnginePath = '/Library/WebServer/Documents/blah/library/Twig/';
$twigTemplatePath = '/Library/WebServer/Documents/blah/application/layouts/scripts/TwigTemplates/';
$twigCachePath = $twigTemplatePath."compilationCache/";

require_once "$twigEnginePath/Autoloader.php";

// register the twig autoloader
Twig_Autoloader::register();

// $loader = new Twig_Loader_String();
// $twig = new Twig_Environment($loader);

$loader = new Twig_Loader_Filesystem($twigTemplatePath);
//$twig = new Twig_Environment($loader, array('cache'=>$twigCachePath));
$twig = new Twig_Environment($loader);

$template = $twig->loadTemplate('listview.html');

$docdatajson = '[{"title":"Mr","firstname":"Rob","surname":"Ganly","function":"test"}]';
$docdata = json_decode($docdatajson, true);

$template->display(array(
                         'pageTitle'=>'Data List Test View',
                         'docs'=>$docdata
));

Anger, wit and sadness: banners @ the Dublin march against austerity.

Banners are perhaps the most succinct way to get a point across in a protest environment such as the November 2010 Dublin march against austerity. There’s something very ‘human’ about them, particularly when pitched against the might of [the rotten legacy of] a corrupt government and exploitative bankers who steered Ireland toward such severe economic and social uncertainty.

Amongst the images of inexhaustible Irish wit and defiance was the most poignant picture I have seen so far; a little girl with a banner that read ‘please look after me’.

Putting the N in cuts

Putting the N in cuts!

I don't need sex...

I don't need sex...

Where's Justin Bieber?

Marching under duress? :)

Says it all

Simple messages are often the most effective...

Save the children

Here's to a brighter future...

Removed window reflections with photoshop

I hadn’t used Photoshop for a while until the other day when I needed to remove some reflections from a photo (that were only noticed after the pictures were uploaded).

The clone stamp tool is great! (click the image for a more detailed look).

Guthrum's window with reflections etc.

Shop window with reflections etc.

Shop window with reflections etc. removed

Shop window with reflections etc. removed

Jobserve.com search changes, a UX regression.

Edit 09/01/2012:
Since my last post on this subject Jobserve have updated their UI to enable the selection of ALL industry sectors when conducting a search, thus reducing the amount of clicks needed to accomplish a blanket industry search. Not selecting an industry now also defaults to searching all industry sectors also, which is satisfactory behaviour.

My only criticism now is that when clicking on the industry sector dropdown the ‘Select All Industries’ check box should be selected by default, which would be consistent with the behaviour of the search undertaken when actioned from this UI state. Anyhow, I’m guessing others must have realised this flaw (or perhaps Jobserve read this post! ;) ) and corrected it; Progress!

Original Post:

Like many IT contractors I have used good old Jobserve many-a-time over the years, enjoying its simple but effective interface and layout.

One of the main things that I liked about it was the speed at which you could set your criteria and fire off a search.  It was literally: type search term -> hit enter.  This would then search ALL jobs in ALL industries (that Jobserve catered for, of course).  Recently however they changed the user interface (UI) which in my opinion has spoiled the user experience (UX) (note diligent use of acronyms :) ).

“Si fractum non sit, noli id reficere”.

Now what happens when I go to search in the same manner that I used to, is that the page submits (looking like it is conducting a search) then reloads after hitting the server and tells me that I must select an industry. Err, ok (a bit of client-side validation would’ve been a nice way to save this uneccessary wait…).  So I select the dropdown and, unusually contained within the dropdown, I see a list of checkboxes.  Right, I think to myself that I don’t really mind what industry/sector I’m working in, in fact I quite like the working in different types of environment, so I just want to select them all.  Oh, wait, there’s no select all checkbox, so I can’t.

So it seems that the only way I can ensure that I’m not missing out on a term-hit for any job across all industries is to check all 17 checkboxes contained within the dropdown (which I feel itself is a bit alien and not very user-friendly).  That plus clicking the dropdown amounts to 18 MORE clicks than I had to do previously to conduct the same search across the same job sectors.

I’m not normally the type to bemoan something as trivial as a negative UI change but it is slightly shocking that a site/application the size of Jobserve (who have over 5.5 million unique visitors a month and sponsor Colchester United) let such a sizeable usability mistake slip past the user acceptance (UA) testing phase; if there was one that is.  More importantly, it is annoying for me! (and most probably a lot of other users).

If that many users did the same search as described above, that’d be an extra 90 million or so uneccessary clicks per month.  Thus I think it is safe to say that this constitutes a prime example of a UI and UX change mistake.

Lastly, and as an aside, on Firefox (i haven’t checked in any other browsers) when the page is loading you get an awkward-looking multiple-select box which displays and then transforms and springs into a dropdown with the checkboxes inside, momentarily throwing the form all over the place.  It just looks wrong.

For reference, here’s the old main Jobserve search interface:

http://replay.waybackmachine.org/20090205112807/http://www.jobserve.us/homepage.aspx