Skip to content

Instantly share code, notes, and snippets.

@chucktrukk
Created February 12, 2010 20:41
Show Gist options
  • Save chucktrukk/302961 to your computer and use it in GitHub Desktop.
Save chucktrukk/302961 to your computer and use it in GitHub Desktop.
<?php
/*
This is a simple example.
I use h2o for all of my modx templating needs, because the php is kind of verbose. And h2o is as simple as [++] placeholders.
( http://wiki.github.com/speedmax/h2o-php/ )
Twig is also a nice option. ( http://www.twig-project.org/ )
*/
$parent = isset($parent) ? $parent : $modx->documentIdentifier;
$results = $modx->getDocumentChildrenTVarOutput($parent, '*');
/* The following would be included like so:
$template = isset($template) ? $template : false;
if( is_readable($template) || $template !== false)
{
include_once $modx->config['base_path'] . '/'.$template;
} else {
echo 'File not found';
}
*/
?>
<?php if( ! $results): ?>
No results were found
<?php else: ?>
<div class="this-is-my-wrapper">
<h2>Woohoo! We got results... below</h2>
<?php foreach($results as $document): ?>
<div class="item">
<h3><?php echo $document['pagetitle'] ?></h3>
<div class="item-content">
<?php echo $document['content']; ?>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment