Skip to content

Instantly share code, notes, and snippets.

@chucktrukk
Created January 28, 2011 21:11
Show Gist options
  • Save chucktrukk/800952 to your computer and use it in GitHub Desktop.
Save chucktrukk/800952 to your computer and use it in GitHub Desktop.
<?php
// &file=`assets/foo/bar.php` indicates the file to include
// &return=`1` return explicit content from return statement in included file
// default behavior is to use output buffering to capture the content from the include
$output = '';
if (isset($file) && file_exists($modx->config['base_path'] . $file)) {
if (!isset($return) || $return == false) {
ob_start();
include ($modx->config['base_path'] . $file);
$output = ob_get_contents();
ob_end_clean();
} else {
$output = include ($modx->config['base_path'] . $file);
}
} else {
$path_parts = pathinfo($file);
return sprintf('The file: %s was not found', $path_parts['basename']);
}
return $output;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment