REC Template inheritance & shadow files

When REC moved to a responsive template, we also introduced the new concept of template inheritance & shadow files.

Template inheritance might not be new if you've worked with other systems templates such as Wordpress or Magento. You can think of it in REC similar to how Wordpress and others have parent & child templates.

How does it work?

At REC we provide base parent templates that get upgraded over time with new features and content. This also provides a base 960 and responsive template.

Then you can override the files from this template in the site template folders.

Files at the same location in a child template will override those in the parent template.

That's pretty much it.

You can do some more fancy things in the html twig files by extending specific blocks of a page. (I'll come back to this later). Bus aside from this, template inheritance for us is, here's a base template. You have site templates that are child templates of those base parent templates. But you can also make you own child templates off of the the other child templates. This allows you to layer a sites themes. E.g. some sites may have a Halloween or Christmas theme that just changes a couple files and adds some css. In this case, responsive-base is the parent theme to the child-responsive site which is the current active theme. But when Christmas rolls around, the Christmas theme is switched on, and it is a child theme of the responsive-site theme.

So what are shadow files?

Now you know ow the inheritance works with child files overriding the parent ones. You also know that a child folder will only have the files that are overriding the parent inside.

However, wouldn't it be great if you could see the folder structure how the system does? That's where shadow files come in.

When showing the template folders and files for the current template, in admin we also show the parents files where the file is not overridden. These are shadow files. They are shadows of where the real file would be from the parent template.

Via admin you can click to view or extend this file into the child template to work with.

Why not override them all?

When we push updates in REC we sometimes make changes to the base template files. We try to avoid anything major to keep your live sites from changing, but we'll happily add new functionality or fix.

When you override the file, you loose these updates to that file. In most cases that's fine as your site is staying in the state it was and you can always get a diff of what has changed and apply changes if wanted. But if you're not making any changes to the file, you might as well leave the file not extended and then get automatic new features & fixes applied.