Created
May 22, 2024 10:56
-
-
Save 0test/44353f6a67ea5a40aa38c7f9a58c2eed to your computer and use it in GitHub Desktop.
TraitFilter.php
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
<?php | |
namespace EvolutionCMS\Main\Controllers; | |
use EvolutionCMS\Main\Controllers\Helpers\Helper; | |
/** | |
* Трейт для использования | |
* eFilter | |
*/ | |
trait TraitFilter | |
{ | |
/** | |
* Ставим плейсхолдер efilterForm | |
*/ | |
public function makeFilter() | |
{ | |
evo()->runSnippet('eFilter', [ | |
'ajax' => 1, | |
'css' => 0, | |
'remove_disabled' => 0, | |
'changeState' => 1, | |
'cfg' => 'custom', | |
'useMultiCategories' => 1, | |
]); | |
$efilterForm = evo()->getPlaceholder('eFilter_form') ?? ''; | |
$this->data['efilterForm'] = $efilterForm; | |
} | |
/** | |
* Возвращаем результаты | |
* в плейсхолдер catalog | |
* а пагинацию в pages | |
*/ | |
public function getCatalog() | |
{ | |
$json = evo()->runSnippet('eFilterResult', [ | |
'parents' => evo()->documentObject['id'], | |
'api' => 1, | |
'tvList' => 'price,mainphoto', | |
'tvPrefix' => '', | |
'display' => '32', | |
'depth' => '3', | |
'paginate' => 'pages', | |
'addWhereList' => 'c.template = 5', | |
'filters' => 'AND(tvd:availability:isnot:1)', | |
'prepare' => ['EvolutionCMS\Main\Controllers\Helpers\Images::resizeMainPhoto'], | |
'config' => 'paginate:custom' | |
]); | |
if (!empty($json)) { | |
$arr = json_decode($json, 1); | |
} | |
$this->data['catalog'] = $arr; | |
$this->data['pages'] = evo()->getPlaceholder('pages'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment