Best Answer CB9TOIIIA , 14 July 2015 - 11:45
Рабочий код
public function columns($layoutName, $objects) { static $itemCount = 0; $cols_num = $this->_params->get('template.' . $layoutName . '_cols', 1); $cols_order = $this->_params->get('template.' . $layoutName . '_order', 1); $vars = array( 'cols_num' => $cols_num, 'cols_order' => $cols_order ); // init vars $i = 0; $columns = array(); $column = 0; $row = 0; $countObjects = count($objects); $rows = ceil($countObjects / $cols_num); if ($countObjects > 0) { foreach ($objects as $object) { if ($cols_order) { // order down if ($row >= $rows) { $column++; $row = 0; $rows = ceil(($countObjects - $i) / ($cols_num - $column)); } $row++; $i++; } else { // order across $column = $i++ % $cols_num; $column = $i; } if (!isset($columns[$column])) { $columns[$column] = ''; } $itemCount++; if ($itemCount == 2) { $columns[$column] .= 'Реклама'; } if ($object instanceof Item) { $columns[$column] .= $this->renderItem($object); } else { $columns[$column] .= $this->render($layoutName, $object, $vars); } } return $this->render($layoutName . '_columns', $columns, $vars); } return false; }Go to the full post