Pezholio

Widgetising Local Government Content

| Comments

John Smith's - because it's got a widget (Not that I'd actually drink the stuff)

With the recent publication of the Digital Britain report and Gordon Brown calling on Tim Berners-Lee to help open up access to government data, there’s been a lot of talk about public organisations opening up data.

Most of this has focused around APIs and linked data (something I’m very passionate about already), but there’s much simpler ways to get data out there that might be useful to those people who might have a website, know their way a bit round HTML, but aren’t willing to get their hands dirty with XML, JSON or RDF.

I’m talking of course, about widgets, these are little bits of (often Javascript) code that people can copy and paste into their own websites. These can then be used by local blogs, newspapers or other websites to publish your content in a quick and easy way.

I’ve had a go at doing a few widgets, publishing food safety inspections and planning applications as widgets and I’m looking to do more in the future. Fellow blogger and techy Philip John has even turned one of our widgets into a Wordpress-compatible widget, which I’m proudly sporting on the right here.

Essentially, what you’re doing is pulling information from a database (using PHP or whatever server-side technology you fancy) and outputting it as javascript code, wrapping it all in a document.write function. You can also use inline styling to style your widget, making sure you override any potential styles that might be overridden by the user’s stylesheet. A quick and dirty example is below:

` ?php

$query = “SELECT * FROM database”;

$result = mysql_query($query) or die(mysql_error());

echo “document.write(‘”;

echo ”

"font-size: 18px; font-weight: bold;">Planning Applications for Foo on Bar Council

”;

Comments