datakick Posted August 29, 2019 Share Posted August 29, 2019 Hello everyone, I'm presenting you my newest addition to my modules portfolio -- Child Theme module. You can use it to, well, create child theme. This can be very handy if you want to modify your theme without loosing the ability to install future updates. When you create child theme using this module, you will find new directory inside your /themes folder. This new theme is initially almost empty, it contains only config.xml file. But surprisingly, if you use this theme, your store will look the same as if you used parent theme directly. That's because module automatically finds missing files in parent(s) directories. You can now change individual files (templates, javascript, css) inside the new theme and the changes will be applied. You can do this by either manually copying the file from parent theme to the new theme. Or you can use built-in feature of this module to edit themes. Testing You can test the module on my demo account Purchase You can purchase the module in my store for EUR39.99 childtheme-0_1_0.zip 4 Link to comment Share on other sites More sharing options...
the.rampage.rado Posted August 29, 2019 Share Posted August 29, 2019 Looks promosing! What will be the price? Link to comment Share on other sites More sharing options...
datakick Posted August 29, 2019 Author Share Posted August 29, 2019 1 hour ago, the.rampage.rado said: Looks promosing! What will be the price? around 40eur Link to comment Share on other sites More sharing options...
datakick Posted August 29, 2019 Author Share Posted August 29, 2019 I received a PM asking if it's possible to use this module to implement ps17 like template inheritance. I'll answer publicly Short answer: yes, if supported by parent theme Long answer: my module overwrites the whole template file. So, if you want to make a tiny change somewhere, you need to copy the whole template file and make the change in it For example, if we have a template <h1>{$page_name}</h1> <div> {foreach $list as $item} <div>{$item}</div> {/foreach} </div> and we want to change the page title from <h1> to <h2>, we need to create an override with this content: <h2>{$page name}</h2> <div> {foreach $list as $item} <div>{$item}</div> {/foreach} </div> This is not very extensible and flexible. If the parent file changes, we will need to copy the changes to the override. Fortunately, smarty contains template inheritance feature. This feature allows us to wrap portion of template into the {block}{/block} tags. And then we can overwrite individual blocks. So, our example would change into something like this: Parent template: {block name='page-header'} <h1>{$page_name}</h1> {/block} {block name='page-content'} <div> {foreach $list as $item} {block name='item-content'} <div>{$item}</div> {/block} {/foreach} </div> {/block} Child template: {extends file='parent:template.tpl'} {block name='page-header'} <h2>{$page_name}</h2> {/block} Parent template is a little bit more complicated with these additional blocks. But child template is much more verbose -- it says to extend parent template, and then says how the extension would work --- only change block with name 'page-header'. The rest of the parent template will be used automatically. This is how ps17 theme works. And you can do exactly the same with this module. But of course, the parent theme the child theme extends must contain the {block}...{/block} syntax. Otherwise there is nothing to extend, and we can only overwrite the whole files. Unfortunately, I doubt there are any ps16 themes using this {block} approach (maybe I'm wrong). So, if you want to use this template inheritance, you should ask your theme developers to implement it. Link to comment Share on other sites More sharing options...
SeaSky Posted August 29, 2019 Share Posted August 29, 2019 Looks great! Will test it and try to come back with some feedback! Link to comment Share on other sites More sharing options...
datakick Posted August 30, 2019 Author Share Posted August 30, 2019 13 hours ago, SeaSky said: Looks great! Will test it and try to come back with some feedback! Great. Let me know how the testing went -- if you want to test it on your server, PM me your domain name, I'll generate a license for you Link to comment Share on other sites More sharing options...
zonk Posted August 30, 2019 Share Posted August 30, 2019 Theme editor looks nice, I would get the module for that alone. But I don't understand what are children themes for? What's the benefit? Why can't I edit the theme directly? Link to comment Share on other sites More sharing options...
datakick Posted August 30, 2019 Author Share Posted August 30, 2019 47 minutes ago, zonk said: Theme editor looks nice, I would get the module for that alone. But I don't understand what are children themes for? What's the benefit? Why can't I edit the theme directly? Well, I like the online editor as well. I'm even tempted to release a separate module that will allow you to edit all your php/css/js/tpl files from back office. Someone might find it useful. Regarding your question - you can, of course, edit your parent theme directly. The module will allow you to do so. But it it will warn you not to do that. The reason is that you will have hard time to update your parent theme. You would loose your modifications when you update your theme to newer version. When you create child theme, all your modification are located in this theme only. You can safely update your parent theme. Your child theme will receive all new files, except those that you have overwritten. I hope that makes sense Link to comment Share on other sites More sharing options...
haylau Posted August 30, 2019 Share Posted August 30, 2019 1 hour ago, datakick said: Well, I like the online editor as well. I'm even tempted to release a separate module that will allow you to edit all your php/css/js/tpl files from back office. Someone might find it useful. Regarding your question - you can, of course, edit your parent theme directly. The module will allow you to do so. But it it will warn you not to do that. The reason is that you will have hard time to update your parent theme. You would loose your modifications when you update your theme to newer version. When you create child theme, all your modification are located in this theme only. You can safely update your parent theme. Your child theme will receive all new files, except those that you have overwritten. I hope that makes sense So for example: We have modified our Panda theme so that it shows current stock level on the product.TPL file. (I add a few lines of code) Everytime we upgrade the theme I have to go back to that file and do the changes again. Using your module will enable us to upgrade the theme but the product.tpl file will remain unchanged? Or the file will be changed but your module will over ride just those lines of code we have added? Link to comment Share on other sites More sharing options...
datakick Posted August 30, 2019 Author Share Posted August 30, 2019 8 minutes ago, haylau said: Using your module will enable us to upgrade the theme but the product.tpl file will remain unchanged? Or the file will be changed but your module will over ride just those lines of code we have added? The first one -- product.tpl will remain unchanged. Of course, it's would be best to implement the second option, but it's much more complicated. It could work in some cases, but sometimes it wouldn't -- that's the generic problem with diffing and patching algorithms. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now