Skip to content

Instantly share code, notes, and snippets.

@dzhuryn
Created July 30, 2018 14:16
Show Gist options
  • Save dzhuryn/5b25795beac7fbd9aa4df095307910d3 to your computer and use it in GitHub Desktop.
Save dzhuryn/5b25795beac7fbd9aa4df095307910d3 to your computer and use it in GitHub Desktop.
prepareWrap
<?php
/** @var $_DocLister DocLister */
/** @var $data array */
$placeholders = $data['placeholders'];
$categoryTpl = $_DocLister->getCFGDef('categoryTpl');
$products = explode('<!--product-->',$placeholders['dl.wrap']);
$products = array_filter($products);
$groups = [];
$index=0;
foreach ($products as $product){
$groups[$index] .= $product;
$index++;
if($index >= ceil(count($products)/2)){ $index=0;};
}
$placeholders['dl.wrap'] = '';
foreach ($groups as $group) {
$placeholders['dl.wrap'] .= DLTemplate::getInstance($modx)->parseChunk($categoryTpl,['dl.wrap'=>$group]);
}
return $placeholders;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment