Skip to content

Instantly share code, notes, and snippets.

@andronex
Forked from Realetive/autoTemplate.php
Created October 20, 2019 21:30
Show Gist options
  • Save andronex/6691ca9dfaa6e91e36672acaaf67f197 to your computer and use it in GitHub Desktop.
Save andronex/6691ca9dfaa6e91e36672acaaf67f197 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