Override Plone Templates Using z3c.jbot

How to use the z3c.jbot Plone to override default templates in Plone

First you must make sure ZopeSkel and PasteScript are installed. Modify your buildout to look like the following:

[buildout]
...
parts =
zopeskel

[zopeskel]
recipe = zc.recipe.egg
eggs =
ZopeSkel
PasteScript

Run a buildout:

bin/buildout

Get to your ${instance} folder src directory.

Issue the following command:

../bin/zopeskel plone addon.name

This will create the empty add-on package.

Locate the configure.zcml file within the package

Modify it to look like so:

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:five="http://namespaces.zope.org/five"
    xmlns:i18n="http://namespaces.zope.org/i18n"
    xmlns:browser="http://namespaces.zope.org/browser"
    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
    i18n_domain="dan.noresults">

  <five:registerPackage package="." initialize=".initialize" />

  <genericsetup:registerProfile
      name="default"
      title="dan.noresults"
      directory="profiles/default"
      description="Installs the dan.noresults package"
      provides="Products.GenericSetup.interfaces.EXTENSION"
      />
  <!-- -*- extra stuff goes here -*- -->

  <include package="z3c.jbot" file="meta.zcml" />
  <browser:jbot directory="a_directory" />

</configure>

Create the directory you have registered in the configure.zcml file (see include and browser lines towards bottom, also don't forget to add the browser declaration at the top: xmlns:browser="") in the same directory as said configure.zml file.

For example:

mkdir a_directory

Inside the above directory you need to create a file which will override the original. For example, to override the search page we would go to portal_view_customizations on a working Plone site, find the template you wish to override and copy the "template file" line. Then merely replace any slashes "/" with points ".".

EG;

plone.app.search/search.pt

Would then be located in the previously mentioned directory (registered using the configure.zcml file) and named:

plone.app.search.search.pt

Simple as that. Install it as per the usual development add-on process (add to eggs, zcml and src sections in buildout.cfg) and when you go back to view the template you'll see the "template file" line will have changed to your add-ons template.

Eg:

/home/dan/plone/zeoserver/src/dan.noresults/dan/noresults/no_search_results/plone.app.search.search.pt