-
AuthorPosts
-
fabiojordan Friend
fabiojordan
- Join date:
- August 2014
- Posts:
- 48
- Downloads:
- 20
- Uploads:
- 2
- Thanks:
- 8
- Thanked:
- 5 times in 5 posts
August 23, 2017 at 3:47 pm #1058203Hi.
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-23Right 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 ModeratorLuna Garden
- Join date:
- July 2011
- Posts:
- 2617
- Downloads:
- 80
- Uploads:
- 96
- Thanks:
- 78
- Thanked:
- 453 times in 425 posts
August 24, 2017 at 10:04 am #1058384Try as below:
Go to JA K2 Filter >> Option >> set as this capture: http://easycaptures.com/fs/uploaded/1136/3290181797.pngfabiojordan Friendfabiojordan
- Join date:
- August 2014
- Posts:
- 48
- Downloads:
- 20
- Uploads:
- 2
- Thanks:
- 8
- Thanked:
- 5 times in 5 posts
August 24, 2017 at 12:24 pm #1058426Hi, 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 ModeratorLuna Garden
- Join date:
- July 2011
- Posts:
- 2617
- Downloads:
- 80
- Uploads:
- 96
- Thanks:
- 78
- Thanked:
- 453 times in 425 posts
August 25, 2017 at 10:54 am #1058587fabiojordan Friendfabiojordan
- Join date:
- August 2014
- Posts:
- 48
- Downloads:
- 20
- Uploads:
- 2
- Thanks:
- 8
- Thanked:
- 5 times in 5 posts
August 28, 2017 at 2:09 pm #1058955This reply has been marked as private.Luna Garden ModeratorLuna Garden
- Join date:
- July 2011
- Posts:
- 2617
- Downloads:
- 80
- Uploads:
- 96
- Thanks:
- 78
- Thanked:
- 453 times in 425 posts
August 29, 2017 at 10:13 am #1059151Mo0nlight ModeratorMo0nlight
- Join date:
- September 2014
- Posts:
- 707
- Downloads:
- 38
- Uploads:
- 107
- Thanked:
- 99 times in 97 posts
August 31, 2017 at 3:37 am #1059573Hi.
You could try this.
Open the file:
/components/com_jak2filter/models/itemlist.phpLook for.
$sql .= empty($where) ? '' : ' AND ' . implode(' AND ', $where);
Change to.
$sql .= empty($where) ? '' : ' AND (' . implode(' OR ', $where) .')';
fabiojordan Friendfabiojordan
- Join date:
- August 2014
- Posts:
- 48
- Downloads:
- 20
- Uploads:
- 2
- Thanks:
- 8
- Thanked:
- 5 times in 5 posts
August 31, 2017 at 1:24 pm #1059689Wonderful, 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-07The component gives wrong results. Maybe there’s some kind of trick in that line to make it work in both ways.
Thanks again!
Mo0nlight ModeratorMo0nlight
- Join date:
- September 2014
- Posts:
- 707
- Downloads:
- 38
- Uploads:
- 107
- Thanked:
- 99 times in 97 posts
September 1, 2017 at 8:29 am #1059854Hi.
Revert the previous edit.
And you could try this.Edit file:
/components/com_jak2filter/models/itemlist.phpLook 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 Friendfabiojordan
- Join date:
- August 2014
- Posts:
- 48
- Downloads:
- 20
- Uploads:
- 2
- Thanks:
- 8
- Thanked:
- 5 times in 5 posts
September 2, 2017 at 3:02 pm #1059987Hi, 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.1 user says Thank You to fabiojordan for this useful post
-
AuthorPosts
This topic contains 9 replies, has 3 voices, and was last updated by fabiojordan 7 years, 2 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum