Created
January 9, 2016 09:32
-
-
Save sonicpunk/9b36575752c0dd1d6d15 to your computer and use it in GitHub Desktop.
rightTemplate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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; | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is depreciated. Another option https://gist.github.com/bfncs/1474540