[ckan-dev] CKAN template question

Sean Hammond sean.hammond at okfn.org
Mon Sep 17 09:16:47 UTC 2012


> I've skimmed a bit of the Genshi documentation but I'm hoping someone
> on this list can give me a quick answer :-)
> 
> We're trying to modify the HTML of our CKAN 1.7 implementation
> following the documentation here:
> 
> http://docs.ckan.org/en/latest/theming.html
> 
> Specifically, it says: "If you are re-theming the site, we recommend
> you over-ride layout.html, which is empty but inherits from
> layout_base.html. This will mean you can upgrade the site more easily
> in the future."
> 
> Does this mean I should copy the provided layout_base.html into
> my_custom_templates/layout.html and then modify THAT file?  Is that
> the "best practice" way to modify the default layout template?

That is the right way to do it, yes.

Note that the copies of the templates in your extension have to have the
same directory and filenames as the originals, so it should be something
like: my_extension/templates/layout_base.html.

Also note that you need to use the extra_template_paths and
extra_public_paths settings to tell CKAN where to find your custom
templates. You can just put this in your ini file:

http://docs.ckan.org/en/ckan-1.7.1/theming.html#adding-and-overriding-files-and-templates

or your extension code can do it itself, here's an example of setting it
that way:

https://github.com/NewAmsterdamIdeas/ckanext-cmap/blob/master/ckanext/cmap/configurer.py

By the way, CKAN 2.0 (currently in development) has a much nicer system
for overriding templates, where you don't need to copy the whole file.

P.S. If you're using CKAN 1.7 you should be looking at
docs.ckan.org/en/ckan-1.7.1/, not docs.ckan.org/en/latest/

> 
> Thanks!
> Jim
> 
> --
> -----
> Jim Craner, 2012 Fellow
> Code for America
> jim at codeforamerica.org
> (+1) 773-809-4546
> http://codeforamerica.org
> 
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev




More information about the ckan-dev mailing list