test
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • fabiojordan Friend
    #1058203

    Hi.

    I want to know how can I search in multiple date fields and get results for ANY items with one of them selected.

    I mean, I have 5 Extra Fields of date type. I want the JA K2 Filter to check all of them in the same date and return any item that matches at least one of those Extra Fields.

    I’m trying to make links so the user can see quickly all the items checked with that specific date, like this:
    http://www.cafecomfilme.com.br/filmes-na-tv?xf_82=2017-08-23&xf_98=2017-08-23&xf_86=2017-08-23

    Right now, it doesnt show anything, because its trying to get items that match ALL of that parameters.

    How can I achieve that?

    Thanks in advance!

    Luna Garden Moderator
    #1058384

    Try as below:
    Go to JA K2 Filter >> Option >> set as this capture: http://easycaptures.com/fs/uploaded/1136/3290181797.png

    fabiojordan Friend
    #1058426

    Hi, Luna.

    This option is already set as "Match Any".

    The data fields type dont have this option, its just numeric or string.

    Any other hints?

    Tks

    Luna Garden Moderator
    #1058587

    Could you post backend of your site in private reply for further checking ?

    fabiojordan Friend
    #1058955
    This reply has been marked as private.
    Luna Garden Moderator
    #1059151

    Ok. I will pass your request to the developer, he’ll reply you soon.

    Mo0nlight Moderator
    #1059573

    Hi.

    You could try this.
    Open the file:
    /components/com_jak2filter/models/itemlist.php

    Look for.

    $sql .= empty($where) ? '' : ' AND ' . implode(' AND ', $where);

    Change to.

    $sql .= empty($where) ? '' : ' AND (' . implode(' OR ', $where) .')';
    fabiojordan Friend
    #1059689

    Wonderful, works like charm.

    BUT, now, when I try to use fields like From and To:
    http://www.cafecomfilme.com.br/filmes-na-tv?xf_82_from=2017-08-31&xf_82_to=2017-09-07

    The component gives wrong results. Maybe there’s some kind of trick in that line to make it work in both ways.

    Thanks again!

    Mo0nlight Moderator
    #1059854

    Hi.

    Revert the previous edit.
    And you could try this.

    Edit file:
    /components/com_jak2filter/models/itemlist.php

    Look for

            $sql = '';
            $where = array();

    Add this below:

            $where2 = array();

    Look for.

                                case 'range':
                                    preg_match('/^\d+\|\d+/', $value, $m);
                                    if (empty($m)) break;
                                    list($from, $to) = explode('|', $value);
                                    if($from != '') {
                                        $from = (int) $from;
                                        $searchPattern = $prefix.$this->rgRange($from, 1);
                                        $where[] = "(i.extra_fields REGEXP ".$db->quote($searchPattern).")";
                                    }
                                    if($to != '') {
                                        $to = (int) $to;
                                        $searchPattern = $prefix.$this->rgRange($to, 0);
                                        $where[] = "(i.extra_fields REGEXP ".$db->quote($searchPattern).")";
                                    }
                                    break;
                                case 'from':
                                    preg_match('/^\d+\-\d+\-\d+/', $value, $m);
                                    if (empty($m)) break;
                                    if($value != '') {
                                        $searchPattern = $prefix.$this->rgRange($value, 1, 'date');
                                        $where[] = "(i.extra_fields REGEXP ".$db->quote($searchPattern).")";
                                    }
                                    break;
                                case 'to':
                                    preg_match('/^\d+\-\d+\-\d+/', $value, $m);
                                    if (empty($m)) break;
                                    if($value != '') {
                                        $searchPattern = $prefix.$this->rgRange($value, 0, 'date');
                                        $where[] = "(i.extra_fields REGEXP ".$db->quote($searchPattern).")";
                                    }
                                    break;

    Change to:

                                case 'range':
                                    preg_match('/^\d+\|\d+/', $value, $m);
                                    if (empty($m)) break;
                                    list($from, $to) = explode('|', $value);
                                    if($from != '') {
                                        $from = (int) $from;
                                        $searchPattern = $prefix.$this->rgRange($from, 1);
                                        $where2[] = "(i.extra_fields REGEXP ".$db->quote($searchPattern).")";
                                    }
                                    if($to != '') {
                                        $to = (int) $to;
                                        $searchPattern = $prefix.$this->rgRange($to, 0);
                                        $where2[] = "(i.extra_fields REGEXP ".$db->quote($searchPattern).")";
                                    }
                                    break;
                                case 'from':
                                    preg_match('/^\d+\-\d+\-\d+/', $value, $m);
                                    if (empty($m)) break;
                                    if($value != '') {
                                        $searchPattern = $prefix.$this->rgRange($value, 1, 'date');
                                        $where2[] = "(i.extra_fields REGEXP ".$db->quote($searchPattern).")";
                                    }
                                    break;
                                case 'to':
                                    preg_match('/^\d+\-\d+\-\d+/', $value, $m);
                                    if (empty($m)) break;
                                    if($value != '') {
                                        $searchPattern = $prefix.$this->rgRange($value, 0, 'date');
                                        $where2[] = "(i.extra_fields REGEXP ".$db->quote($searchPattern).")";
                                    }
                                    break;

    Look for.

    $sql .= empty($where) ? '' : ' AND ' . implode(' AND ', $where);

    Change to

            $sql .= empty($where) ? '' : ' AND (' . implode(' OR ', $where).' )';
            $sql .= empty($where2) ? '' : ' AND (' . implode(' AND ', $where2).' )';
    fabiojordan Friend
    #1059987

    Hi, Mo0nlight.

    Thanks for the code. Works like charm. But I’ve made some changes.

    My code doesnt have these parts:

                                        preg_match('/^\d+\|\d+/', $value, $m);
                                        if (empty($m)) break;

    With those codes, It wasnt working for the type of search From-To. So, I removed them and now its working fine 🙂

    Thanks for the help. Maybe you can implement this feature (or option, I dont know how to call it) in a future update.

    Anyway, best extension and awesome work from Joomlart.

    Keep up the good work!
    Best regards.

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

This topic contains 9 replies, has 3 voices, and was last updated by  fabiojordan 7 years, 3 months ago.

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