Created
October 6, 2018 19:30
-
-
Save Pathologic/a87c2fa4165da9b14044b048b8dcf95c to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* parseTemplate | |
* | |
* to parse chunks with DLTemplate | |
* | |
* @category snippet | |
* @version 1.0.0 | |
* @author Pathologic (https://github.com/pathologic) | |
*/ | |
if (isset($modx->tpl) && isset($tpl)) { | |
$twigTemplateVars = array( | |
'modx' => $modx, | |
'debug' => isset($debug) ? (bool)$debug : false, | |
'config' => &$modx->config, | |
'plh' => &$modx->placeholders, | |
'ajax' => isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest', | |
'_GET' => $_GET, | |
'_POST' => $_POST, | |
'_COOKIE' => $_COOKIE, | |
'_SESSION' => $_SESSION | |
); | |
if (!empty($modx->documentObject)) { | |
$resource = array(); | |
foreach ($modx->documentObject as $key => $value) { | |
$resource[$key] = is_array($value) ? $value[1] : $value; | |
} | |
$twigTemplateVars['resource'] = $resource; | |
$twigTemplateVars['documentObject'] = &$modx->documentObject; | |
} | |
return $modx->tpl->parseChunk($tpl, $params); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment