Skip to content

Instantly share code, notes, and snippets.

@Pathologic
Created October 6, 2018 19:30
Show Gist options
  • Save Pathologic/a87c2fa4165da9b14044b048b8dcf95c to your computer and use it in GitHub Desktop.
Save Pathologic/a87c2fa4165da9b14044b048b8dcf95c to your computer and use it in GitHub Desktop.
<?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