Processwire templates and how to create them

Posted 5th Sep 2017

#setup #templates

Templates are what you will use to store your fields as well as outputting field data when required.

A few basic principles:

  • Templates are used to store fields.
  • Templates can be used to create pages.
  • Templates can have an associated file which can be used to output a page created using that template (i.e. blog-entry template with a blog-entry.php file).
  • Templates can be used to simply store data without an associated page.
  • Templates do not need to have an associated file, for example, a 'settings' template which could have fields such as siteEmail, sitePhoneNumber, siteLogo etc.
  • Templates can use an alternate file.

Admin > Setup > Templates

Your templates are listed on this page. Notice some have not had the 'label' set so the default label is the template name.

The templates section in the admin
The templates section in the admin Zoom

You can choose an existing one by selecting the template name, which allows you to edit various things.

Template edit in admin
Template edit in admin Zoom

Or create a new one by selecting 'Add New Template' which takes you to the next screen.

Adding a new template in admin
Adding a new template in admin Zoom

When you add a new template, after you name it, you can duplicate fields from another template to save you some time if it is similar to an existing template.

Another thing to note is that you can create multiple templates here by having spaces in-between the words. For example, you wanted templates for 'categories', 'contact' and 'product', edit the name field with these words, then select 'Add Templates'.

Creating multiple templates
Creating multiple templates Zoom

You'll see the new templates in the list.

Multiple templates created
Multiple templates created Zoom

So now you know how to create templates. As mentioned, processwire templates hold fields, so next you could learn about adding fields to templates and removing fields from templates.

Feedback & support

I hope you enjoyed this tutorial. You can support pwtuts by following on @pwtuts. You can also donate at paypal.me/swcarrey to help support the site which would be awesome!

Related tutorials / See all

Suggest a tutorial

Please note: I do not store any of this information, it's simply used to send me an email. Your email address is required so I can get clarification on your request if needed.