/*
* Template to Children
*
* Children will inherit the template specified in the
* TplToChild TV. Use it for any container that you need
* to specify a diffrent template than the parent
*
* Configuration:
* check the OnDocFormPrerender event
* make sure this plugin is called after Inherit parent Template plugin
*
* create a TV named TplToChild,
* Input Type: DropDown List menu
* Input Option Values: @SELECT templatename, id FROM [+PREFIX+]site_templates
* Choose the templates you would use it for
*
* Version 0.2
*
* based on Inherit Template Plugin
*/
global $content;
$e = &$modx->Event;
switch($e->name) {
case 'OnDocFormPrerender':
if(($_REQUEST['pid'] > 0) && ($id == 0)) {
$sql = "SELECT * FROM ".$modx->db->config['table_prefix']."site_tmplvars tvvar JOIN ".$modx->db->config['table_prefix']."site_tmplvar_contentvalues tvcv ON tvvar.id = tvcv.tmplvarid AND tvcv.contentid = '".$_REQUEST['pid']."' WHERE name = 'TplToChild'";
$rs= $modx->dbQuery($sql);
$row = $modx->fetchRow($rs);
if(isset($row['value'])){
$content['template'] = $row['value'];
}
}
break;
default:
return;
break;
}
