Inherit Selected Template (Fixed) 1.0.0-rc1
Released Jun 10, 2010 by mrpresley
This is a copy of "Inherit Selected Template" by Tobyl that is updated with instructions that work. The correction is in the instructions for the code in the "Input Option Values" in the TV. I don't take any credit for the corrected code (found it from Bruno17 in the forums at http://modxcms.com/forums/index.php/topic,49258.0.html).
Download 4kb (191 downloads)
Inherit Selected Template is a replacement for the "Inherit Page Template" plugin. By default newly created child documents will inherit the parents template (as with the original plugin) However, selecting a template in the parent container's 'Inherit Template' TV will make all new child documents (of that parent) inherit the selected template instead. This works recursively through the document tree. *This version has corrected code in the instructions allowing this to work.
1. If you have the Inherit Page Template plugin installed, edit it or otherwise create a new plugin. Paste the contents of the plugin.inherit.selected.template.02.php.txt file into the plugin code field. (don't forget to exclude the opening and closing php tags).
2. Tick the OnDocFormPrerender event on the plugin's System Event tab.
3. On the configuration tab paste the following line into the plugin configuration field:
&tvSource=TV Name;string;inheritTpl&levels=parent levels;string;5
Now create a TV.
1. Name it inheritTpl (see 1) and assign it to the templates of your choice.
2. Set the caption to 'Inherit Template' and the description to something like Children inherit this template'
3. Set the TV input options to (this is the corrected code):
@SELECT templatename,id FROM `modx_site_templates`
4. leave the default option empty
Usage:
Edit the document/container which children you want to have inherit a specific template. In the Inherit Template list box TV choose one of the available templates. All new children of this container will now inherit this template.
In the list of templates there is one extra choice 'Inherit Parent' which will restore the original Inherit Parent Template plugin functionality for this containers children. This is useful for multi level containers where you don't want a fixed inherited template.
Notes:
(1) You can name the TV differently of course as long as you set the 'tv source' config parameter of the plugin to the same name.
(2) Make sure you disable or delete the original Inherit Parent Template plugin. Using this plugin makes the original obsolete.
Installation Instructions
Plugin Installation:1. If you have the Inherit Page Template plugin installed, edit it or otherwise create a new plugin. Paste the contents of the plugin.inherit.selected.template.02.php.txt file into the plugin code field. (don't forget to exclude the opening and closing php tags).
2. Tick the OnDocFormPrerender event on the plugin's System Event tab.
3. On the configuration tab paste the following line into the plugin configuration field:
&tvSource=TV Name;string;inheritTpl&levels=parent levels;string;5
Now create a TV.
1. Name it inheritTpl (see 1) and assign it to the templates of your choice.
2. Set the caption to 'Inherit Template' and the description to something like Children inherit this template'
3. Set the TV input options to (this is the corrected code):
@SELECT templatename,id FROM `modx_site_templates`
4. leave the default option empty
Usage:
Edit the document/container which children you want to have inherit a specific template. In the Inherit Template list box TV choose one of the available templates. All new children of this container will now inherit this template.
In the list of templates there is one extra choice 'Inherit Parent' which will restore the original Inherit Parent Template plugin functionality for this containers children. This is useful for multi level containers where you don't want a fixed inherited template.
Notes:
(1) You can name the TV differently of course as long as you set the 'tv source' config parameter of the plugin to the same name.
(2) Make sure you disable or delete the original Inherit Parent Template plugin. Using this plugin makes the original obsolete.