Including Custom Templates in Packages

Concrete5 theme developers can easily release their themes in the Concrete5 package format. The Concrete5 Package format is the format used by the Concrete5 marketplace, as well by any developer who wants to keep certain bits of Concrete5 functionality bundled together, for easy updating or deployment. Packages can contain lots of different types of Concrete5 functionality, including themes, blocks, single pages and their controllers, custom code and more. This list of items that can be included in packages also includes custom block templates – and this is very useful when combined with a theme.

Many packaged Concrete5 themes contain not just the theme, but also custom view templates for core block types. Sometimes themes are built using different markup than core blocks, and its easier to change the view markup of a block type in a custom template than it is to make the theme's CSS conform to Concrete5's built-in markup. Additionally, packaged themes cannot override the default view template of a block type! That means, in order to change the markup of a block type's view layer, the theme is going to have to ship with custom templates. Fortunately, this is really easy to do.

Example Theme

Let's take the Urbanic theme in my previous examples. This theme's package directory might look like this.

  • packages
    • theme_urbanic
      • controller.php
      • icon.png
      • themes
        • urbanic

With the theme assets coming inside the "urbanic" directory. If I want to ship custom templates for the Auto-Nav and the Page List block, I just create those directories within the package, as I would within my own application/ directory.

  • packages
  • theme_urbanic
    • controller.php
    • icon.png
    • blocks
      • autonav
      • page_list
    • themes
      • urbanic

Each block type directory contains a "templates/" directory, with the same structure as custom templates elsewhere. That's it! You don't need to register these custom templates anywhere or install them using code when the theme is installed. They simply work when placed in this location.

Loading Conversation