Tag Archives: codeforthepeople

Facetious: CFTP’s Advanced Search plugin for WordPress

facetious
Out of the box: a Facetious widget in Twenty Ten

We’re proud to announce that Facetious, a plugin we’ve been working on for quite some time, has now been released in the official WordPress repository. And we’d like to thank the UK taxpayer for his/her assistance in writing it.

We do a lot of work for government departments, and on several recent projects, there’s been a requirement for an ‘advanced’ or ‘faceted’ search form. This allows you to search by post type, by keyword, by taxonomy, and by month – all together. You can see it on the Government Olympic Communication site, for example, where we let you search its video library (post type) by keyword, and/or theme, department, nation/region, video quality, or month of upload.

We did something similar for the Commission on Devolution in Wales; and it’s a key feature of another site due to go live in the next month or so.

We’re in good company, by the way: you’ll see a very similar search form on GovUK’s Inside Government pages, for example.

It became immediately obvious that we could write the code as a plugin, for instant reuse on any WordPress site. We called it Facetious, because it had the word ‘facet’ in it. And in keeping with our open source principles – not to mention the fact that the development work had been funded by government departments – we decided we would release it publicly in the official WordPress plugin repository.

Out of the box, it provides an enhanced ‘search form’ widget, which you can drop into any WordPress sidebar. If you want to add a customised form into your own post templates, we’ve made that easy too: it’s all detailed in the plugin’s readme file.

Facetious isn’t a ‘search engine’ per se: it’s just a simple way to construct complex multi-dimensional queries. The results are gathered using WordPress’s built-in search function, which doesn’t try to be anything too clever. If you’re looking for smarter search results, you’ll need a different plugin. (Maybe Relevanssi or something.)

Oh, there’s one more thing.

Search URLs in WordPress are the platform’s last unpretty ‘permalink’. Nobody wants to see ?s=keyword in their address bar; and it isn’t possible to cache query-string URLs using something like WP Super Cache. So we’ve created a new permalink structure for searches as part of Facetious, and your search URL now looks like /search/keyword/ – or /search/month/201302/keyword/whatever/category/uncategorized/. This will be applied to any search: not just those submitted via a Facetious form.

If you want to give it a try on your own WordPress site, just go to Plugins in the admin area, and search for it. If you’re a developer, and you’d like to help us improve Facetious, it’s also on Github. Pull requests welcome. ;)

My thanks to Nick H, Nick S and Sara P for letting us experiment on their sites over the past few months: and to John Blackbourn, for doing such a fantastic job turning my hacky code into a plugin to be proud of.

Five Years

It came as quite a shock a few weeks ago, when I realised Puffbox Ltd was fast approaching its fifth birthday – specifically, the fifth anniversary of its incorporation at Companies House. Perhaps because I’m a parent of two young girls, five years feels like a significant milestone: it’s the age at which a child starts ‘proper’ schooling, and begins the journey down the long road to adulthood. It also marks the longest time I’ve ever stayed in a job.

Over those five years, I’ve learned to go with the flow. When I started Puffbox, the plan was to offer advisory services to government and/or large corporate clients. But I soon realised that people weren’t short of advice: what they needed were people who could actually be trusted to make stuff. And you may find this hard to believe, but I didn’t start out with an attachment to any particular technology platform either.

I’ve also learned that I’m good at spotting the currents within that flow. Looking back, I’ve done pretty well at picking out the technologies – and just as importantly, the people – who were going to have real, lasting impact in my field. Occasionally I find myself trawling back through my blog archives, nervously checking to see if I dismissed something (or someone) which went on to be huge… and to my great relief, finding very few examples thereof.

A couple of years ago, I could see that people’s perception of me was changing. I used to be a government person who happened to know a bit about WordPress. I’m now a WordPress person who happens to know a bit about government. Perhaps that’s inevitable, given that it’s six or seven years since I was last a Civil Servant. Maybe it’s pure coincidence that it coincides (broadly) with the 2010 general election, and the ushering-in of the new order. Maybe it’s a mark of the growing maturity of my chosen technology platform, and the community around it.

And so, once again, it’s time to let the flow take me somewhere new.

I first met Simon Wheatley at the first UK WordCamp, back in 2008. His presentation on WordPress plugin development was truly fantastic: it was the first time anyone had explained the process in terms I could understand. His code wasn’t bad either. I started to bring him in to help on projects which were beyond my own technical capability – like DFID’s blogs site, launched three and half years ago, and still going strong.

As many of you will know, for the last couple of years, we’ve been working as a partnership in all but name. Nearly every large-scale job has been a joint effort. We speak the same language; in a lot of areas, our skills and experience complement each other beautifully; and he’s very understanding, when I commit heinous crimes against web development.

So last summer, after much beating around the bush, we agreed it was time to formally merge our operations, into a new and explictly WordPress-centric business. Our projects are reaching a scale where they need more than a ‘one man band’ to support them. It will be more reassuring to clients – and indeed to ourselves! – if the two of us are legally bound together, and it gives us a platform upon which to build a proper company, whatever that means.

On 25 January this year – a date we chose deliberately – Simon and I formed that new company: Code For The People Ltd. And with the start of the new tax year, and the closure of several public sector projects, now is the time to activate it.

The name is deliberately provocative. It’s a statement of our confidence in the open source business model, and our belief in building websites to suit the people who will use them – and indeed, those who will run them – rather than the technology. It’s also a commitment to keep giving back to the community of which we’re a part: you’ll note, for example, that Mr Wheatley’s name features once again on the Credits for the forthcoming WordPress v3.4 release.

What does this mean in practice? At least to begin with – and who knows what’ll happen after? – things will continue as they always have done. It’ll be me, Simon and a handful of hand-picked contacts, doing the same basic things, in the same basic way. Any projects or contracts which were started under the Puffbox name will be completed in the Puffbox name, and will be invoiced as Puffbox. However, any new work will be in the name of Code For The People. Once all our current contracts reach completion, Puffbox Ltd will bow out gracefully.

I’ve spoken in the past about retiring from the front line: I just can’t see myself coding into my 40s, and with various new things coming along – responsive design, HTML5, LESS – now seems like a good time. The new company obviously gives me a path towards that exit, but I doubt it’ll be happening any time soon.

We’ll still play our part in the ‘gov geek’ community. We’re already quietly working on a couple of big government jobs, for delivery in the next couple of months. And yes, puffbox.com will continue as my personal blog, with a particular focus on government and politics. But we’re doing more and more work outside government these days; and for the moment at least, I don’t feel government needs us in the way it did a year or two back. (And to be quite frank, it told us as much at this year’s UKGovCamp.) Mission accomplished? – maybe, maybe.

To all those who have inspired, supported, contributed to and done business with Puffbox Ltd over the last five years – from the bottom of my heart, thank you.

We’ll be launching Code For The People’s website shortly, as soon as we decide what technology to build it on (joke). In the meantime, you’ll find us on Twitter at @cftp