Skip to content

Instantly share code, notes, and snippets.

@sergant210
Last active May 11, 2016 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergant210/6975e37ad02605a95cee684c77d6cf7e to your computer and use it in GitHub Desktop.
Save sergant210/6975e37ad02605a95cee684c77d6cf7e to your computer and use it in GitHub Desktop.
<?php
require_once '_fenom.php';
class FenomPlus extends FenomX
{
/**
* @inheritdoc
*/
protected function _addDefaultModifiers()
{
parent::_addDefaultModifiers();
$modx = $this->modx;
/** @var pdoToolsPlus $pdo */
$pdo = $this->pdoTools;
$fenom = $this;
// Get chunk from file
$this->_modifiers['chunk'] = function ($input, $options = array()) use ($modx, $pdo) {
$input = str_replace(array('../','./'),'',$input);
$pdo->config['tplPath'] = isset($options['tplPath']) ? $options['tplPath'] : MODX_CORE_PATH . 'elements/chunks';
if (!preg_match('/(.html|.tpl)$/i', $input)) {
$input .= '.tpl';
}
$content = $pdo->parseChunk('@FILE '. $input, $options);
unset($pdo->config['tplPath']);
return $content ? $content : $input;
};
// Get snippet from file
$this->_modifiers['snippet'] = function ($input, $options = array()) use ($modx, $pdo) {
$input = str_replace(array('../','./'),'',$input);
$pdo->config['tplPath'] = isset($options['tplPath']) ? $options['tplPath'] : NULL;
$output = $pdo->includeSnippet($input, $options);
unset($pdo->config['tplPath']);
return $output ? $output : $input;
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment