One of the first things I always do when making a new install is extending the ’Inherit Parent Template’ plugin to first check the siblings.
I rename it to ’Inherit Sibling or Parent template’
Most of the time a sibling seems a much better reference because that will be at the same level. (Hence ’sibling’)
/*
* Inherit Template from Sibling or, if no siblings available, Parent
* Written By Raymond Irving - 12 Oct 2006
* Adapted by Maarten Wolzak - feb 2008
*
* Simply results in new documents inherriting the template
* of their first sibling (or parent folder if no siblings)
* upon creating a new document
*
* Configuration:
* check the OnDocFormPrerender event
*
* Version 1.0.1
*
*/
global $content;
$e = &$modx->Event;
switch($e->name) {
case 'OnDocFormPrerender':
if(($_REQUEST['pid'] > 0) && ($id == 0)) {
if($sibl = $modx->getDocumentChildren($_REQUEST['pid'], 1, 0, 'template')){
$content['template'] = $sibl[0]['template'];
}else if($sibl = $modx->getDocumentChildren($_REQUEST['pid'], 0, 0, 'template')){
$content['template'] = $sibl[0]['template'];
}else if($parent = $modx->getPageInfo($_REQUEST['pid'],0,'template')) {
$content['template'] = $parent['template'];
}
}
break;
default:
return;
break;
}
I would be glad if this could be integrated in upcoming versions!
Thanks,
Maarten