Date Picker date range

  • Posts: 139
  • Thank you received: 1
10 years 5 months ago #161268

I am using the date picker addon for a custom field. It works well except that it doesn't go back far enough e.g. The year drown allows users to choose years from 2014 to 2004. unfortunately they need to go back further. Currently they can only do this by selecting 2004 and then choosing the dropdown again to get lower options.

Any way of changing this but getting the default year to be 10 years earlier, or using some other method?

Please Log in or Create an account to join the conversation.

  • Posts: 26159
  • Thank you received: 4028
  • MODERATOR
10 years 5 months ago #161290

Hi,

I don't understand what you are talking about.
There is no year limitation in the date picker.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 139
  • Thank you received: 1
10 years 5 months ago #161322

Hi, the following screen cast shows the issue for clearly :)

http://youtu.be/NxlnyPT9R7w

Please Log in or Create an account to join the conversation.

  • Posts: 82910
  • Thank you received: 13379
  • MODERATOR
10 years 5 months ago #161328

Hi,

Thanks for the video.

You would have to add the line:

$dateOptions[] = 'yearRange: \'c-20:c+20\'';
after the line:
$dateOptions[] = 'changeYear:true';
in the file plugins/hikashop/datepickerfield/datepickerfield.php
c-20 means 20 years before current year. And c+20 means 20 years after current year. so you can adapt if you want.

Please Log in or Create an account to join the conversation.

  • Posts: 139
  • Thank you received: 1
10 years 5 months ago #161474

Thanks for that but I am not sure where to put these lines as I can't find

$dateOptions[] = 'changeYear:true';

See the code for the file below:
<?php

/**

 *

 */

class plgHikashopDatepickerfield extends JPlugin

{

	/**

	 *

	 */

	public function __construct(&$subject, $config) {

		parent::__construct($subject, $config);



		$this->loadLanguage('plg_hikashop_datepickerfield', JPATH_ADMINISTRATOR );

    }



	/**

	 *

	 */

	public function onFieldsLoad(&$fields, &$options) {

		$me = new stdClass();

		$me->name = 'datepickerfield';

		$me->text = JText::_('DATE_PICKER');

		$me->options = array('required', 'default', 'columnname', 'format', 'allow', 'datepicker_options');



		$fields[] = $me;



		$opt = new stdClass();

		$opt->name = 'datepicker_options';

		$opt->text = JText::_('DATE_PICKER_OPTIONS');

		$opt->obj = 'fieldOpt_datepicker_options';



		$options[$opt->name] = $opt;

	}

}



if(defined('HIKASHOP_COMPONENT')) {

	/**

	 *

	 */

	require_once( dirname(__FILE__).DS.'datepickerfield_class.php' );

}

Please Log in or Create an account to join the conversation.

  • Posts: 82910
  • Thank you received: 13379
  • MODERATOR
10 years 5 months ago #161490

Hi,

Sorry it's in the file plugins/hikashop/datepickerfield/datepickerfield_class.php that you want to do that change

The following user(s) said Thank You: abasel

Please Log in or Create an account to join the conversation.

  • Posts: 139
  • Thank you received: 1
10 years 5 months ago #161559

Worked like a dream :-)

if(!empty($datepicker_options['change_year'])) 
		{
			$dateOptions[] = 'changeYear:true';
			$dateOptions[] = 'yearRange: \'c-20:c+20\'';
		}

Please Log in or Create an account to join the conversation.

Time to create page: 0.062 seconds
Powered by Kunena Forum