Skip to content

Instantly share code, notes, and snippets.

@bigin
Created December 27, 2018 20:20
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 bigin/a18dfa929a925c811cf7c32eae1beaee to your computer and use it in GitHub Desktop.
Save bigin/a18dfa929a925c811cf7c32eae1beaee to your computer and use it in GitHub Desktop.
<?php
...
public function renderSection($sectionName, $params = array())
{
if($sectionName == 'FrontendItemDetails') {
$this->renderFrontendItemDetails();
} elseif($sectionName == 'FrontendCategoryList') {
$this->renderFrontendCategoryList();
} else {
return parent::renderSection($sectionName, $params);
}
}
private function renderFrontendCategoryList()
{
$rows = '';
$params = array(
'section' => 'frontend',
'selector' => 'active=1',
'filter' => 'group',
'pageurl' => $this->processor->config->pageNumberParam
);
$result = $this->processor->getCategories($params);
// If you want to order the categories additionally according to their position, remove next comment:
//$result['categories'] = imanager()->getItemMapper()->filterSimpleItems('position', 'DESC', 0, 0, $result['categories']);
if(isset($result['total']) && $result['total'] > 0 && !empty($result['categories']))
{
foreach($result['categories'] as $category)
{
if($this->processor->config->categoryImageResize)
{
$path = \ImCatalog\Util::getResizedUrl($category,
$this->processor->config->categoryImageIndex,
$this->processor->config->categoryImageMaxWidth,
$this->processor->config->categoryImageMaxHeight,
'resize'
);
} else { $path = IM_SITE_URL.$category->image[$this->processor->config->categoryImageIndex]; }
if(empty($path))
{
$path = IM_SITE_URL . 'plugins/' . $this->processor->config->pluginId . '/images/thumb300x300.png';
}
$replace = array();
foreach($category as $name => $value) {
if($name == 'image') {
$replace[$name] = $path;
continue;
}
$replace[$name] = ($name == 'image_title') ? $value[0] : $value;
}
$replace['href'] = './'.$category->slug.$this->processor->config->trailingSlash;
$replace['info_link'] = \ImCatalog\Util::i18n_r('categorylist_infolink_label');
$replace['category_info'] = $this->parser->render($this->categoryInfo, $replace);
$rows .= $this->parser->render($this->categoryRow, $replace);
}
$this->content = $rows;
$this->pagination = $result['pagination'];
$this->total = $result['total'];
}
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment