Inherit Selected Template 0.2.0
Released Feb 12, 2009 by tobyl
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.
Download 4kb (817 downloads)
Inherit Selected Template is a replacement for the "Inherit Page Template" plugin which lets you optionally use a TV (template variable) in a container document to select a template which all children of that container will inherit.
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:
@EVAL $sql = 'SELECT templatename,id FROM '.$modx->db->config['table_prefix'].'site_templates';$a=array(array('',''),array('Inherit Parent','-1')); $v = $modx->db->query($sql);while($rows = mysql_fetch_row($v)) $a[]=$rows; return $a;
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:
@EVAL $sql = 'SELECT templatename,id FROM '.$modx->db->config['table_prefix'].'site_templates';$a=array(array('',''),array('Inherit Parent','-1')); $v = $modx->db->query($sql);while($rows = mysql_fetch_row($v)) $a[]=$rows; return $a;
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.