test
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • imaxenio2293 Friend
    #183246

    I need to appear in alphabetical order select fields filtrates k2 extra fields.
    Thanks

    MoonSailor Friend
    #476850

    Hi,

    Do you mean that you want to order here ?

    Send me FTP account of your site, i will fix it for you


    1. 12-20-2012-10-15-31-AM
    rsystems Friend
    #476925

    I’d like to know solution too, now if I create another K2 Extra field, it’s not sorted on alphabet but on number of entry/ID, it’s ugly.

    imaxenio2293 Friend
    #476935

    That’s right, I want those extra fields appear ordered and that the results also appear in alphabetical order.

    For security reasons, not allowed to give me FTP account but if I indicate the solution or files to play, I resolve. thanks :((

    imaxenio2293 Friend
    #476978

    I of the fields items to the SELECT extra fields appear sorted alphabetically (AZ)


    1. buscador
    MoonSailor Friend
    #477066

    Hi @imaxenio2293, @rsystems:

    Open file modules/mod_jak2filter/helper.php and add code
    [PHP]
    class ja_object_sorter
    {
    var $object_array;
    var $sort_by;

    function _comp($a,$b)
    {
    $key=$this->sort_by;
    if ($this->object_array[$a]->$key == $this->object_array[$b]->$key) return 0;
    return ($this->object_array[$a]->$key < $this->object_array[$b]->$key) ? -1 : 1;
    }

    function _comp_desc($a,$b)
    {
    $key=$this->sort_by;
    if ($this->object_array[$a]->$key == $this->object_array[$b]->$key) return 0;
    return ($this->object_array[$a]->$key > $this->object_array[$b]->$key) ? -1 : 1;
    }

    function sort(&$object_array, $sort_by, $sort_type = “ASC”)
    {
    $this->object_array = $object_array;
    $this->sort_by = $sort_by;
    if ($sort_type == “DESC”)
    {
    uksort($object_array, array($this, “_comp_desc”));
    }
    else
    {
    uksort($object_array, array($this, “_comp”));
    }
    }
    }
    [/PHP]

    in bottom file.

    Apply for select box : find function
    [PHP]
    public function getSelect($field,$ranges = NULL){
    $defaut_values = JRequest::getVar(“xf_{$field->id}”,null);
    $values = json_decode($field->value);
    [/PHP]
    add code
    [PHP]
    $ja_object_sorter = new ja_object_sorter ();
    $ja_object_sorter ->sort($values,’name’);
    [/PHP]
    after “$values = json_decode($field->value);” and before “foreach ($values as $f)”

    Apply for multi select box :find function:
    [PHP]
    public function getMultipleSelect($field,$ranges = NULL){
    $values = json_decode($field->value);
    [/PHP]

    add code
    [PHP]
    $ja_object_sorter = new ja_object_sorter ();
    $ja_object_sorter ->sort($values,’name’);
    [/PHP]
    alter “$values = json_decode($field->value);” and before “foreach ($values as $f)”

    Apply for Magic Select : find function:

    [PHP]
    public function getMagicSelect($field,$ranges = NULL){
    $auto_filter = (int) @$this->params->get(‘auto_filter’);
    $defaut_values = JRequest::getVar(“xf_{$field->id}”,null);
    if(!is_array($defaut_values)) {
    $defaut_values = array($defaut_values);
    }
    $values = json_decode($field->value);
    [/PHP]

    add code
    [PHP]
    $ja_object_sorter = new ja_object_sorter ();
    $ja_object_sorter ->sort($values,’name’);
    [/PHP]
    after “$values = json_decode($field->value);” and before “foreach ($values as $f)”

    MoonSailor Friend
    #477067

    Note : please backup file “modules/mod_jak2filter/helper.php” before changing :p

    rsystems Friend
    #478279

    Can this also be an option in the next update?

    Arvind Chauhan Moderator
    #478712

    <em>@rsystems 353216 wrote:</em><blockquote>Can this also be an option in the next update?</blockquote>

    Yes, it would be part of next version release.

    Regards

Viewing 9 posts - 1 through 9 (of 9 total)

This topic contains 9 replies, has 4 voices, and was last updated by  Arvind Chauhan 11 years, 11 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum