Last active
July 23, 2019 03:47
-
-
Save bigin/e6cfffe54efdf6835553ec9203a1a767 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
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