-
AuthorPosts
-
Fred Tep Friend
Fred Tep
- Join date:
- September 2014
- Posts:
- 76
- Downloads:
- 46
- Uploads:
- 7
- Thanks:
- 15
- Thanked:
- 2 times in 1 posts
March 25, 2016 at 11:58 am #904652Hi,
first of all, Thanks for this amazing tool.
I’m just wondering if there is a way to filter by year. I know I can use the custom range but I’ve been asked if that was possible.
I’d like to have a dropdown list with all the years of the different items in K2.THanks in advance for your answers
Luna Garden ModeratorLuna Garden
- Join date:
- July 2011
- Posts:
- 2617
- Downloads:
- 80
- Uploads:
- 96
- Thanks:
- 78
- Thanked:
- 453 times in 425 posts
March 28, 2016 at 9:15 am #905381Hi,
We have another custom type for Date time Range to Year range, you could try this code we’ve updated here: https://www.joomlart.com/forums/topic/date-range-slider/
Fred Tep FriendFred Tep
- Join date:
- September 2014
- Posts:
- 76
- Downloads:
- 46
- Uploads:
- 7
- Thanks:
- 15
- Thanked:
- 2 times in 1 posts
March 30, 2016 at 8:51 am #906625Hi,
Thanks for your answer. I read this topic but it’s no use for me as I don’t have an extrafield with the year.
I’d like to search in the created date and only pick up the year from there.Luna Garden ModeratorLuna Garden
- Join date:
- July 2011
- Posts:
- 2617
- Downloads:
- 80
- Uploads:
- 96
- Thanks:
- 78
- Thanked:
- 453 times in 425 posts
March 31, 2016 at 2:29 am #906966Mo0nlight ModeratorMo0nlight
- Join date:
- September 2014
- Posts:
- 707
- Downloads:
- 38
- Uploads:
- 107
- Thanked:
- 99 times in 97 posts
April 4, 2016 at 8:22 am #908860Hi Fred,
You can try with my tweak below:
-
Go to file: /modules/mod_jak2filter/helper.php
- Add this new code to the end of file:
function getItemDate() { $db = JFactory::getDbo(); $sql = 'SELECT DISTINCT YEAR(created) FROM #__k2_items'; $db->setQuery($sql); $items = $db->loadColumn(); $html=array(); $html[] = JHTML::_('select.option', '', JText::_('SELECT_DATE_RANGE'), 'value', 'text'); foreach ($items AS $item) { $html[] = JHTML::_('select.option', $item, $item, 'value', 'text'); } $input = JFactory::getApplication()->input; $current_year = $input->get('jadtrange', '', 'STRING'); return JHTML::_('select.genericlist', $html, 'jadtrange', array('class'=>'jadtrange'), 'value', 'text', $current_year); }
Edit File : /modules/mod_jak2filter/tmpl/default.php Find for
<?php echo $filter_by_daterange; ?>
Around Line : 90 Change To:
<div style="display:none;" ><?php echo $filter_by_daterange; ?></div> <?php echo getItemDate(); ?>
Then Find For :
// multi ordering and sortable order. jQuery(document).ready(function () {
Add new code below:
jQuery('.jadtrange').change(function(){ if (jQuery(this).val() == '') { jQuery('#jak2filter<?php echo $module->id;?>').find('#dtrange').val(''); jQuery('#jak2filter<?php echo $module->id;?>').find('#sdate_<?php echo $module->id;?>').val(''); jQuery('#jak2filter<?php echo $module->id;?>').find('#edate_<?php echo $module->id;?>').val(''); return; } jQuery('#jak2filter<?php echo $module->id;?>').find('#dtrange').val('range'); jQuery('#jak2filter<?php echo $module->id;?>').find('#sdate_<?php echo $module->id;?>').val(jQuery(this).val()+'-01-01'); jQuery('#jak2filter<?php echo $module->id;?>').find('#edate_<?php echo $module->id;?>').val(jQuery(this).val()+'-12-31'); });
That’s all. Regards.
-
AuthorPosts
This topic contains 4 replies, has 3 voices, and was last updated by Mo0nlight 8 years, 7 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum