Forums › Forums › Search & Filter Pro › Search by date for ancient documents
- This topic has 57 replies, 2 voices, and was last updated 6 years, 3 months ago by Anonymous.
-
Anonymous(Private) August 1, 2018 at 12:13 pm #184238
I’m making a website with an archive of ancient documents – http://newspapers1908.tolstoy.ru/ I need to implement a search by date. The oldest document is dated 1 August 1908. But by default the form shows the current date and search range plus / minus 10 years: 2008-2028. August 1, 1908 can only be entered manually-1/08/1908. Is it possible to make the year of the earliest document (1908) appear by default? Thank You!
Trevor(Private) August 1, 2018 at 12:46 pm #184247Our date filtering requires that the date is stored in the database in the format YYYYMMDD
For legacy data, the only way to achieve this would be to create a new field for this type of date and write a SQL script to take the old dates and convert them to this new field. It would not be too complex, but you would need to employ the services of a third party SQL coder to do this.
Trevor(Private) August 2, 2018 at 10:36 am #184403Ah, sorry, I misunderstood. You mean the datepicker range is not far enough back or forwards? You would need to add a small amount of javascript to the page to alter the minDate and maxDate of the jQuery UI Datepicker.
I think it would look something like this (untested, but if it doesn’t work I can set it up on my server to check for you), you need to add your dates:
<script> (function ( $ ) { $(jqueryIdentifier).datepicker('option', { minDate: new Date(startDate), maxDate: new Date(endDate) }); }(jQuery)); </script>
jqueryIdentifier needs to be changed to be the identifier for the field with the datepicker.
If you are unsure about this, get back to me and I will see if I can resolve this for you in your site.
Trevor(Private) August 6, 2018 at 12:49 pm #184587Hi
Try it now. This code disables the Year Selection (as you only want 1908, correct?), limits the range to 1908, and sets the default date to January 1, 1908.
jQuery(document).on("sf:init", ".searchandfilter", function(){ jQuery("#search-filter-form-108 .sf-datepicker").datepicker('option',{ yearRange: '1908:1908', defaultDate: '1/1/1908', changeYear: false }); });
-
AuthorPosts