CKAN Theming for UoE Open Data Hub

Four weeks ago I started working on customisation of the UoE Open Data Hub.

I started looking at the Drupal CKAN module. I was not able to make much sense of the commited code. This is not surprising as the code had not been formally released yet and I was new to Drupal.

Next, I was pointed to the CKAN Theming Gallery by colleagues on the project. This page had a wiki that pointed you to code examples from various projects – the wiki page has since been deprecated. I found the work done by the Canadian Datadotgc.ca folk on theming the most accessible for a newbie. Based on their ideas, I did some basic theming which consisted  of  adding CSS and overriding templates for the home page and layout. The documentation on CKAN theming is evolving and the latest quick guide for CKAN Theming can be found here.  The advantages of theming is that you don’t alter the CKAN model code, which means upgrading CKAN versions should be easier subject to the  following caveats.

I was working on CKAN 1.4.3 and the UoE Open Data Hub site uses CKAN 1.4.1. I learned the following the hard way:

  • Html tag ids have been added in the newer version. So if you are working on a newer version of CKAN to the deployed version then CSS changes will not necessarily  be backward compatible.
  • Some Python variables changed in the newer version, so template pages used for theming will need to be checked against the default version of the altered templates in the CKAN distribution to discover the new variable names. This problem manifests itself as a Genshi Template error, e.g.,
    WebApp Error: <class ‘genshi.template.eval.UndefinedError’>: “package_list_from_dict” not defined.
    It this case the Python variable which was “package_list_dict” in CKAN 1.4.1 was changed to “package_list_from_dict” in CKAN 1.4.3:
    <!– CKAN VERSION 1.4.1 –>
    <p><strong>Recently changed packages</strong></p>
    ${package_list(c.latest_packages)}
     

    <!– CKAN VERSION 1.4.3 –>
    <p><strong>Recently changed packages</strong></p>
    ${package_list_from_dict(c.latest_packages)}

This entry was posted in Uncategorized by jpinto. Bookmark the permalink.

Comments are closed.