-
AuthorPosts
-
February 19, 2015 at 3:55 pm #203955
Hi,
I have an extrafield “date” with the format is dd-mm-yyy. I want to be able to filter a range of years (i.e. from 1856 till 2011) with the use of a slider.
I realise that I will have to hack the script in order to do this. However this task should not be too difficult, as it is easy with PHP to convert a date format into a number.
Perhaps you can push me in the right direction by telling me where in the script I should start looking in order to make these alterations.
Thanks & regards,
Erik
Luna Garden ModeratorLuna Garden
- Join date:
- July 2011
- Posts:
- 2617
- Downloads:
- 80
- Uploads:
- 96
- Thanks:
- 78
- Thanked:
- 453 times in 425 posts
February 24, 2015 at 10:32 am #560509Luna Garden ModeratorLuna Garden
- Join date:
- July 2011
- Posts:
- 2617
- Downloads:
- 80
- Uploads:
- 96
- Thanks:
- 78
- Thanked:
- 453 times in 425 posts
February 25, 2015 at 9:42 am #560633Hi,
We have a suggestion like this:
1. In module, add range slider to date type format. You can choose the value of year maximum and minimum.
Edit in file: modulesmod_jak2filterelementsk2extrafield.php copy line 270 to 249.
2. In front-end, when searching, add value to make the number to date format, for example user select a range from 1999 to 2010 we will add it to: from 1-1-1999 to 31-12-2010
Edit in file: componentscom_jak2filtermodelsitemlist.php from line 1308 to 1318,
– Check Data type is Date then adding the suffix to minimum value and maximum value.March 22, 2016 at 3:53 pm #903402I can only see
break;
in line 270 and also the same in 249.Can you please explain again what exactly needs to be copied and where?
Thanks
The Captain ModeratorThe Captain
- Join date:
- December 2014
- Posts:
- 66
- Downloads:
- 74
- Uploads:
- 19
- Thanked:
- 11 times in 11 posts
March 25, 2016 at 10:01 am #904629Hi eabe,
You can try with my tweak here:
-
In the file modules/mod_jak2filter/elements/k2extrafield.php, +/ Search the snippet of code:
case 'date': $typeOptions[] = JHTML::_('select.option', $prefix.'date', JText::_('FILTER_TYPE_DATE')); $typeOptions[] = JHTML::_('select.option', $prefix.'daterange', JText::_('FILTER_TYPE_DATERANGE'));
Replace by the code:
case 'date': $typeOptions[] = JHTML::_('select.option', $prefix.'date', JText::_('FILTER_TYPE_DATE')); $typeOptions[] = JHTML::_('select.option', $prefix.'daterange', JText::_('FILTER_TYPE_DATERANGE')); $typeOptions[] = JHTML::_('select.option', $prefix.'rangeslider', JText::_('FILTER_TYPE_RANGE_SLIDER'));
-
In the file components/com_jak2filter/models/itemlist.php, search the snippet of code:
case 'range': list($from, $to) = explode('|', $value); if($from != '') { $from = (int) $from; $searchPattern = $prefix.$this->rgRange($from, 1); $where[] = "(i.extra_fields REGEXP '".$searchPattern."')"; } if($to != '') { $to = (int) $to; $searchPattern = $prefix.$this->rgRange($to, 0); $where[] = "(i.extra_fields REGEXP '".$searchPattern."')"; } break;
Replace by the code:
case 'range': preg_match_all('/[0-9]+/',$field, $matches); $fxid = $matches[0][0]; list($from, $to) = explode('|', $value); if($from != '') { if($this->isDateFX($fxid)) { $from = $from.'-01-01'; $searchPattern = $prefix.$this->rgRange($from, 1, 'date'); }else { $from = (int) $from; $searchPattern = $prefix.$this->rgRange($from, 1); } $where[] = "(i.extra_fields REGEXP '".$searchPattern."')"; } if($to != '') { if($this->isDateFX($fxid)) { $to = $to.'-12-31'; $searchPattern = $prefix.$this->rgRange($to, 0, 'date'); }else { $to = (int) $to; $searchPattern = $prefix.$this->rgRange($to, 0); } $where[] = "(i.extra_fields REGEXP '".$searchPattern."')"; } break;
Hope this helps.
-
AuthorPosts
This topic contains 4 replies, has 4 voices, and was last updated by The Captain 8 years, 8 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum