Create Your Own concrete5 Block Custom Template

Create Your Own concrete5 Block Custom Template

Learn how to enhance your concrete5 website by building custom templates for core blocks


Article by Andy / / Comments / Difficulty 
Create Your Own concrete5 Block Custom Template

Creating your own Custom Templates for the standard built in concrete5 block suite is a great way to enhance both your websites appearance and functionality. What’s more, they can be as simple or as complex as you like; accessible for designers and developers of all levels.

Before you can get hands on with writing a custom template, you will first need to create the directory to hold all of the code. Sounds scary but really it isn’t. concrete5 has been built in such a way that you can extend the app without actually changing any of the core files. Instead you can copy directories to the root of the install, safely leaving the core files untouched. Let me explain more.

For the purpose of this article, we will look at creating a custom template for the concrete5 'Page List' block. First things first - create the directory structure for our files:

  1. From the root of your concrete5 install navigate to ‘concrete > blocks > page_list’. Make a copy of the view.php file somewhere locally on your computer
  2. Next we need to navigate back to the root of our concrete5 install
  3. Open the 'blocks' folder and create a directory called ‘page_list
  4. Within this folder add an other directory this time call it ‘templates
  5. Now you need to create a third directory within this one and call it something relevant to your template. Let’s call it ‘my_pagelist’. This can actually be anything you like; just make sure you use an underscore (_) for any spaces
  6. The directory structure is now complete. Next step is to copy the view.php file you saved earlier into the ‘my_pagelist’ folder.

Easy so far. Right?

We should now have our new page list custom template available for us to use over on our concrete5 website. Simply add a 'Page List' block to your page and configure accordingly. Once saved, click on this block and select ‘Custom Template’ - choosing ‘My Pagelist’ from the options. Publish your page. Congratulations, you are now running a concrete5 page list block using your very own custom template.

Wait a minute, nothing has changed…

That’s right. All we’ve done at this stage is copy over the default view for the concrete5 page list block into a safe place for us to edit without affecting the core app files. You are now free to make changes to this view without changing or damaging any core files.

Join the conversation

comments powered by Disqus