Skip to content

Instantly share code, notes, and snippets.

@Realetive
Created June 12, 2016 03:46
Show Gist options
  • Save Realetive/b92384dc615cd481e5f436d586a2d82f to your computer and use it in GitHub Desktop.
Save Realetive/b92384dc615cd481e5f436d586a2d82f to your computer and use it in GitHub Desktop.
Plugin for setup template by parent resource
<?php
if ( $modx->event->name == 'OnDocFormRender' && $mode == modSystemEvent::MODE_NEW ) {
$template = $modx->runSnippet( 'pdoField', array(
"id" => $_REQUEST['parent']
, "field" => "template"
, "top" => 0
) );
switch ( $template ) {
case 1:
$template = 2;
break;
default:
$template = 1;
break;
}
$modx->controller->setProperty( 'template', $template );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment