In which cases you can use child theme?
1. Using the child theme to override files is better than modifying files directly. If you don't use a child theme, your changes to files will lose when you update your theme to a new version. With the child theme feature, your changes will be safe, which doesn't mean you don't need to check changes in the new version. For example, you have the \templates\_partials\header.tpl file in your child theme, then you still need to check if the \templates\_partials\header.tpl is modified in the new version in the parent theme by comparing files, if it's modified, then you still need to apply all modifications to the header.tpl file in the child theme.
2. Change theme name. For some reason you may want to change your theme name, then you can use the child theme feature to change the name of your theme. Don't change the name of the /themes/transformer/ folder or the /themes/panda/ folder.
Downloads
- Basic child theme of Classic theme (886 downloads)
- Basic child theme of Transformer theme v4 (635 downloads)
- Basic child theme of Panda template v2 (743 downloads)
Upload the main folder in .zip file to the /themes/ folder.
If your theme is older than Panda theme 2.6.1 or the Transformer theme v4.5.1, then you need to copy the /themes/your-theme-name/font-fontello folder to the /themes/child-theme-name/ folder.
How to override a file using child theme.
There are two ways.
1. Override some parts of the template.
Let me use the contact us page as an example. If you have a 3rd party module that requires you to add a piece of code to the bottom of the contact form, then you can create the /templates/contact.tpl file in your child theme, put this code {extends file='parent:contact.tpl'} to the file, now you are able to modify the contact us page. Check the /templates/contact.tpl in parent theme, you would find, what you need to do is to add the code to the bottom of page_content block, which can be done by using this code.
1 2 3 | {block name='page_content' append} Put any content here. {/block} |
If you want to override the /templates/catalog/_partials/product-buy.tpl file, then use this code {extends file='parent:catalog/_partials/product-buy.tpl'}
In most cases, we use this way to override files. To know more about {Block} in Smarty, check this {block} Smarty.
2. Override the whole template.
Let me also use the contact us page as an example. If you want to have a completely different contact us page as the contact us page in the parent theme, create the /templates/contact.tpl file in your child theme, put this code {extends file='page.tpl'} to the file, and then you will be able to do whatever you want to do.
Hi Jonny, there is a problem after creating child theme with icons. For example in Panda2 (april 2018) Theme editor - General, buttons are missing icons and the dialog box with icons to select is empty. You need to copy the directory font-fontello to the child theme as the minimum requirement or correct some url path in parent theme (panda2) sources.
Thanks for reporting, I will find a way to fix it.