Skip to content

Instantly share code, notes, and snippets.

@bigin
Last active July 23, 2019 03:47
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/e6cfffe54efdf6835553ec9203a1a767 to your computer and use it in GitHub Desktop.
Save bigin/e6cfffe54efdf6835553ec9203a1a767 to your computer and use it in GitHub Desktop.
...
private function renderFrontendItemList($args = null)
{
$rows = '';
$tag_selector = '';
$tag_url = '';
if(!empty($_GET['tag'])) {
$tag_selector = '&&tags=%'.$this->imanager->sanitizer->text($_GET['tag']).'%';
$tag_url = '?tag='.$this->imanager->sanitizer->text($_GET['tag']);
}
$params = array(
'section' => 'frontend',
'selector' => 'active=1'.$tag_selector,
'pageurl' => $this->processor->config->pageNumberParam,
'tagurl' => $tag_url
);
$categories = $this->processor->getCategories();
foreach($categories['categories'] as $category) {
$result = $this->processor->getItems($category->id, $params);
if(isset($result['total']) && $result['total'] > 0 && !empty($result['items']))
{
foreach($result['items'] as $item)
{
if($this->processor->config->itemListImageResize)
{
$path = U::getResizedUrl($item,
$this->processor->config->itemListImageIndex,
$this->processor->config->itemListImageMaxWidth,
$this->processor->config->itemListImageMaxHeight,
'resize'
);
} else { $path = $item->image[$this->processor->config->itemListImageIndex]; }
$replace = array();
foreach($item as $name => $value) {
if($name == 'image') {
$replace[$name] = $path;
continue;
}
$replace[$name] = ($name == 'image_title') ? $value[0] : $value;
}
$replace['href'] = './'.$item->slug.$this->processor->config->trailingSlash;
$replace['figure'] = '';
if(isset($replace['image']))
{
$replace['figure'] = $this->parser->render($this->itemFigure, array(
'href' => $replace['href'],
'image' => $replace['image'],
'image_title' => $replace['image_title'],
)
);
// delete unwanted stuff
unset($replace['image']);
unset($replace['image_title']);
}
$tags_wrapper_tpl = '';
if($this->processor->config->displayItemListTags && !empty($item->tags))
{
$tags_tpl = '';
$tags = array_map('trim', explode(',', $item->tags));
if(is_array($tags)) {
foreach($tags as $tag)
{
$tags_tpl .= $this->parser->render($this->tag, array(
'href' => '?tag='.urlencode(strtolower($tag)),
'tag_label' => $tag
)
);
}
$tags_wrapper_tpl = $this->parser->render($this->tagsWrapper, array('tags' => $tags_tpl));
}
}
$replace['tags'] = $tags_wrapper_tpl;
$replace['item_info'] = $this->parser->render($this->itemInfo, array(
'href' => $replace['href'],
'info_link' => U::i18n_r('itemlist_infolink_label')
)
);
$rows .= $this->parser->render($this->itemRow, $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