Skip to content

Instantly share code, notes, and snippets.

@sonicpunk
Created January 9, 2016 09:32
Show Gist options
  • Save sonicpunk/9b36575752c0dd1d6d15 to your computer and use it in GitHub Desktop.
Save sonicpunk/9b36575752c0dd1d6d15 to your computer and use it in GitHub Desktop.
rightTemplate
/* modx event OnHandleRequest */
<?php
if (isset($_GET['a'])) {
$action = $modx->getObject('modAction', $_GET['a']);
if (is_object($action) && $action->get('controller') == 'resource/create') {
$parentID = isset($_REQUEST['parent']) ? (int) $_REQUEST['parent'] : 0;
if ($parent = $modx->getObject('modResource', $parentID)) {
$parentTpl = $parent->get('template');
if ($parentTplObj = $modx->getObject('modTemplate', $parentTpl)) {
if ($props = $parentTplObj->getProperties()) {
$tpl = ($ff = $modx->fromJSON($props['childTemplate'])) ? $ff : null;
if ($tpl) {
$_GET['template'] = $tpl;
}
}
}
}
}
}
@sonicpunk
Copy link
Author

Is depreciated. Another option https://gist.github.com/bfncs/1474540

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment