Сделать сортировку в фильтре по tv полю

Здравствуйте имеется данный фильтр, у него есть поле селект называется выбрать автомобиль тип список.
Подскажите каким образом можно отфильтровать по этому полю.


Вот вёрстка фильтра
<div class="form-selection">
    <form action="[[~3]]" name="f-selection">
        <div class="f-fields plane-1">
            <select name="s-category" id="s-category">
                <option value="0">Выберите тип запасных частей</option>
                [[!getResources? &limit=`0`  &parents=`15` &where=`{"template:=":4}` &sortby=`{"menuindex":"ASC"}` &tpl=`category-item-option-model-selection`]]
            </select>
        </div>
        <div class="f-fields plane-2">
            <select name="s-auto" id="s-auto" onchange="getMod(this.value);">
                <option value="0">Выберите автомобиль</option>
           [[!getResources? &parents=`28` &where=`{"template:=":6}` &tpl=`category-item-option-model-selection-2`&limit=`0`]]
            </select>
        </div>
        <div id="append">[[select-model]]</div>
        <div class="f-button">
            <input type="submit" id="s-sub" name="s-sub" value="Найти">
            <!--<button type="submit">Найти</button>-->
        </div>
    </form>
</div>
Это сниппет selection
<?php
//  [[!getResources? &sortby=`{"menuindex":"ASC"}` &parents=`[[*id]]` &where=`{"template:IN":[5]}` &tpl=`product-list`]]

$auto = $_GET['s-auto'];
$seng = $_GET['s-eng'];
if(!empty($auto) && empty($seng)) {
	$modelfl = array();
	
    $array_ids = $modx->getChildIds($auto, 5, array('context' => 'web'));
    foreach($array_ids AS $item) {
        $modelfl[] = 'model==%'.$item.'%';
    }
    $modelfl_str = implode('||',$modelfl);
}
else if(!empty($seng)) {
	$modelfl_str = 'model==%'.$seng.'%';
}

$filter .= $modelfl_str;
$cat = $_GET['s-category'];

if($cat == 0) {
    $array_ids = $modx->getChildIds(15,1,array('context' => 'web'));
    $cat = implode(",",$array_ids);
}
 
$arr = array(
    'sortby'=>'{"pagetitle":"ASC"}',
    'includeTVs'=>1, 
    'processTVs'=>1, 
    'depth'=> 2,
    'where'=>'{"template:IN":[5]}',
    'tpl'=>'product-list-selection',
    'parents'=>$cat,
    'tvFilters'=>"$filter",
    'limit'=>0);
    $sn = $modx->runSnippet('getResources',$arr);
    
  if(!empty($_GET['s-auto']) || !empty($_GET['s-eng']) || !empty($_GET['s-category'])) {
    if(!empty($sn)) {
        echo '<table class="param-model">';
        echo $sn;
        echo '</table>';
    }
    else {
        echo '<p class="not">По вашему запросу ничего не найдено</p>';
    }
  }
select-model сниппет модели
<?php
if(!empty($_GET['s-auto'])) {
       
    $array_ids = $modx->getChildIds($_GET['s-auto'],6,array('context' => 'web'));
    echo'<div class="f-fields plane-2"><select name="s-eng" id="s-eng"><option value="0">Выберите двигатель</option>';
    foreach($array_ids AS $item) {
        $page = $modx->getObject('modResource', $item);
        $output = $page->get('pagetitle');
        if($_GET['s-eng'] == $item) {
            $cls = ' selected';
        } 
        else {
            $cls = '';
        }
        echo '<option value="'.$item.'"'.$cls.'>'.$output.'</option>';
    }
    echo '</select></div>';
    }
сниппет searchauto
<?php
//  [[!getResources? &sortby=`{"menuindex":"ASC"}` &parents=`[[*id]]` &where=`{"template:IN":[5]}` &tpl=`product-list`]]
 $model = $_GET['f-auto'];
$arr = array(
    'sortby'=>'{"menuindex":"ASC"}',
    'includeTVs'=>1, 
    'processTVs'=>1, 
    'where'=>'{"template:IN":[5]}',
    'tpl'=>'product-list',
    'parents'=>15,
    'tvFilters'=>"model==%$model%");
    echo '<table class="param-model">';
echo $sn = $modx->runSnippet('getResources',$arr);
echo '</table>';
Кто чем подскажет, поможет, буду благодарен обыскал всё, сам почти не разбираюсь в модексе вообще, по этому прошу помощи, нашёл что сортировку можно выполнить по sortbyTV — Сортировка по TV. Указать имя TV. А как и что не понятно.
Григорий
21 июля 2020, 09:38
modx.pro
354
0

Комментарии: 0

Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
0