Skip to content

Instantly share code, notes, and snippets.

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 gayanvirajith/2a43e7325136c7ecca7c to your computer and use it in GitHub Desktop.
Save gayanvirajith/2a43e7325136c7ecca7c to your computer and use it in GitHub Desktop.
Sample ProcessWire function usage.
/**
* Returns site feature set markup
* @return String - html markup of features
*/
function getFeatureSet() {
$pages = wire('pages')->find("template=conversion-feature");
if (!count($pages)) return '';
$out = '';
$config = wire('config');
$perPage = 3;
$featureItems = array_chunk($pages->getArray(), $perPage);
//Create delegate template
$template = new TemplateFile($config->paths->templates . "markup/feature-set.inc");
//assign the rendered view to content variable to show up on _done.php
$template->set('featureItems', $featureItems);
$out .= $template->render();
return $out;
}
//on your output template
<?php $counter = 0;?>
<?php foreach($featureItems as $i => $featureChunk): ?>
<div class="row row-<?php echo $i?>">
<?php foreach($featureChunk as $featureItem):?>
<div class='col-lg-4 col-md-4 col-sm-4 text-center feature'>
<div class='animated hiding' data-animation='fadeInUp' data-delay='<?php echo ($counter*500)?>'>
<?php echo $helper->faIconLong($featureItem->label_text); ?>
<h3><?php echo $featureItem->title ?></h3>
<?php if ($featureItem->body) echo $featureItem->body; ?>
</div>
</div>
<?php ++$counter; endforeach; ?>
</div>
<?php endforeach; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment