A
A
Alexander Ivanov2015-12-02 22:20:59
MODX
Alexander Ivanov, 2015-12-02 22:20:59

How to refine the sorting of numbers through the snippet in MODX REVO?

Such a question, why sorting works fine with pagetitle, but crookedly with the price?
Those. 12000 , 14000 , 4000 , 260000 , 2000 and vice versa?
Is this due to the fact that I messed up something with the date type or something else?

<div class="sort">
        Сортировать: 
          
        
        </div>
        <div id="Collection-content">
        

The snippet itself:
<?php
if($_GET['sort'] == $field and $_GET['dir'] == 'ASC') {$arr='&uarr;';}
if($_GET['sort'] == $field and $_GET['dir'] == 'DESC') {$arr='&darr;';}
if(!$_GET[$field]){
  if($_GET['dir'] == 'ASC'){
    $output = '<a style="color:#000" href="'.$url.'?'.$q.'sort='.$field.'&dir=DESC#prod">'.$name.''.$arr.'</a>';
  } else {
    $output = '<a style="color:#000" href="'.$url.'?'.$q.'sort='.$field.'&dir=ASC#prod">'.$name.''.$arr.'</a>';
  }
} else {
  $output = '<a style="color:#000" href="'.$url.'?'.$q.'sort='.$field.'&dir=ASC#prod">'.$name.'</a>';
}
return $output;

and his assistant:
<?php
$sort = $_GET['sort'];
if($sort == '') {
    $output='&sortby=`{"menuindex":"ASC"}`';
} else {
    $output = '&sortby=`{"'.$sort.'":"'.$_GET['dir'].'"}`';
}
return $output;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2015-12-02
@cimonlebedev

Understood there was an error in filling, text instead of numbers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question