Creating a Template File

First, turn off overrides caching via Dashboard > System & Settings > Optimization > Cache & Speed Settings. Until this is turned off Concrete5 won't look in the application directory unless it knows it has a file in there. Since your custom templates live in the application directory (just like default override block view templates) you'll need to do this.

Next, for whichever block type you're creating the custom template, create the following directory

application/blocks/autonav/templates

You'll likely have an application/blocks directory, probably empty. Make sure you have a directory named autonav (or whatever block type handle you're creating the template for) and within that directory a directory named "templates."

Now, decide what you want your custom template to be called. The name of your template file will translate directly into the name of your custom template, only with Concrete5's standard uncamelcasing applied. If, for example, you want to create a custom template named "Site Map Tree" for the Auto-Nav, you're going to name your custom PHP file "site_map_tree.php". Copy the default view.php file from the core Auto-Nav block type directory into your newly created custom template location.

cp concrete/blocks/autonav/view.php application/blocks/autonav/templates/site_map_tree.php

Now, when you edit an Auto-Nav block within your site, your custom template may be applied from the "Design & Custom Template" menu.

Custom Template 1

Custom Template 2

Just select the custom template, hit save, and you're done! Obviously, you haven't actually customized the template yet, so there's more to do. But you're free to modify the custom template found in your application directory without fear of forking the core, and without worrying about certain places in your site picking up the modifications that are unintended. You can choose when and how to apply your block's custom template.

Read on for more information about automatically including custom JavaScript and CSS assets when your custom templates are used.

Loading Conversation