Home › Forums › Calendar Products › Events Calendar PRO › Change date picker output
- This topic has 17 replies, 3 voices, and was last updated 8 years, 6 months ago by
Palmtree.
-
AuthorPosts
-
September 23, 2017 at 9:33 am #1353802
Palmtree
ParticipantHello codemaster,
I would like to change the way the month display inside date picker calendar which is popup (overlay) option when you filter the event date.
I think by default it outputs like “Sep 2017” when the date picker is displaying September calendar.Currently it says “9月 2017”. It is in Japanese by the way.. And this is automatic (perhaps naturally output based on the language of the wordpress or OS I’m using) so far I didn’t tough any code for this output.
I want to change this to 2017年9月. You notice that the “9 (month)” goes behind the year 2017 and I want to put “年” text right after 2017. Is it something can be done in translation file or….?
Thank you for your support.
PalmtreeSeptember 23, 2017 at 9:34 am #1353804Palmtree
ParticipantThis reply is private.
September 25, 2017 at 2:10 pm #1354547Andras
KeymasterHello Palmtree,
Thanks for getting in touch!
For the datepicker we are using an external library and the date settings in WordPress or The Events Calendar have no effect on this. It looks like not even the browser language has an effect on this, so might be the Operating System language and date format setting as a default.
I will try to check if it can be influenced by some code. Please hang in there while I do this, it might take some time.
Thanks,
AndrasSeptember 25, 2017 at 10:36 pm #1354738Palmtree
ParticipantAndrás thank you for looking at this. I look forward to hearing from you.
September 28, 2017 at 2:59 pm #1356475Barry
MemberHi Palmtree,
Perhaps this snippet will help you:
add_action( 'wp_footer', function() {
echo <<<HTML
<script type="text/javascript">
if (
'function' === typeof jQuery
&& 'function' === typeof jQuery.fn.bootstrapDatepicker
) {
// 1) In this example we're adjusting the jp (Japanese) property,
// to modify the English equivalent we'd access en instead.
//
// 2) The format in this example will result in the year then the
// full month, but all formats as described below are accepted:
// https://bootstrap-datepicker.readthedocs.io/en/latest/options.html#format
jQuery.fn.bootstrapDatepicker.dates.jp['titleFormat'] = 'yyyy MM';
}
</script>
HTML;
}, 1000 );This could be added either to a custom plugin (preferred) or else to your theme’s functions.php file.
Please note that you will probably need to tweak it to get the format you desire, as per the comments in the code itself 🙂
September 28, 2017 at 3:00 pm #1356478Barry
Member…and just for the benefit of other users reviewing this topic, I’d emphasize again the need to read the comments in the code. If you are running an English language site, for example, the above code will probably result in an error unless you swap out the reference to jp with en (and so on for other languages).
September 28, 2017 at 5:25 pm #1356522Palmtree
ParticipantThank you Barry!
I have put following code but the screen went complete white…
add_action( 'wp_footer', function() { echo ' <script type="text/javascript"> if ( 'function' === typeof jQuery && 'function' === typeof jQuery.fn.bootstrapDatepicker ) { jQuery.fn.bootstrapDatepicker.dates.jp['titleFormat'] = 'yyyy年m月'; } </script>'; }, 1000 );Am I missing something?
September 29, 2017 at 4:00 am #1356644Andras
KeymasterHi Palmtree,
I tested Barry’s code and it works. I see you did some adjustment to it and likely that is the cause.
This is a mixed code of php and javascript, so that is why some things might look unusual. Make sure that you copy the code Barry provided as it is.
Specifically the beginning:
echo <<<HTMLand the end
</script> HTML; }, 1000 );Does that do the trick?
A.
September 29, 2017 at 4:36 am #1356656Palmtree
ParticipantHi András,
You are right, I have modified a bit. Now I went back and used the original code shown below… And still doesn’t work. I pasted into theme’s functions.php
Is there something I am still missing here? I appreciate if you could take a look at my code.
add_action( 'wp_footer', function() { echo <<<HTML <script type="text/javascript"> if ( 'function' === typeof jQuery && 'function' === typeof jQuery.fn.bootstrapDatepicker ) { jQuery.fn.bootstrapDatepicker.dates.jp['titleFormat'] = 'yyyy年m月'; } </script> HTML; }, 1000 );September 29, 2017 at 9:26 am #1356796Andras
KeymasterHi,
There are a couple of extra spaces after the closing HTML. You can see it when you select the code. I pointed it out on this screenshot.
Once you remove those spaces it should work.
A.
September 30, 2017 at 5:45 am #1357250Palmtree
ParticipantThis reply is private.
-
This reply was modified 8 years, 7 months ago by
Palmtree.
October 2, 2017 at 3:33 am #1357612Andras
KeymasterHello Palmtree,
No worries at all!
The issue might be that in line 207 you have used so called curly quotes (”) instead of the straight ones (“). That can cause confusion and errors.
Instead of putting it in your functions.php file you can have it as a separate plugin.
I quickly created the plugin version of it for you, you can download it from here:
https://gist.github.com/andrasguseo/08b9f3cff12facd93469c4dab212252d
On the top right of the page you will see a ‘Download ZIP’ button. Click on that and save it. Then unpack and copy only the php file on your server into the wp-content/plugins folder just like that.
Don’t forget to modify the settings in the code to Japanese and your date format.
Then in your admin dashboard go to your plugins and activate it. On the front-end you should see the change.
Let me know how this works out.
Cheers,
AndrasOctober 2, 2017 at 3:35 am #1357613Andras
KeymasterIn case you use the plugin, don’t forget to remove the code from your functions.php. 😉
October 2, 2017 at 5:46 am #1357665Palmtree
ParticipantThis reply is private.
October 3, 2017 at 2:30 am #1358159Andras
KeymasterThis reply is private.
-
This reply was modified 8 years, 7 months ago by
-
AuthorPosts
- The topic ‘Change date picker output’ is closed to new replies.
