The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group
How to use JQuery FullCalendar to display multiple forms' data in a calendar
Hi All
It feels great to give something back to the community!
I'm in the middle of developing a web app as a service and had a need to display the data from two forms in a calendar. In my case I had:
- Form 1 = Service Dates for individual items in an inventory
- Form 2 = Service Dates for items in a wider system
I looked around for a solution and came across the JQuery plugin fullcalendar; this was able to take an array of data and display it in the calendar, to get it working with formidable these were the steps I followed.
- Add the following lines to your themes functions.php (your locations may be different!) to load the required files
- wp_enqueue_style( 'fullcalendar', get_template_directory_uri().'/plugins/fullcalendar/fullcalendar.css' );
- wp_enqueue_script( 'moment', get_template_directory_uri().'/plugins/fullcalendar/moment.js' );
- wp_enqueue_script( 'fullcalendar', get_template_directory_uri().'/plugins/fullcalendar/fullcalendar.js' ); /* fullcalendar */
- Install Code Snippets plugin if you haven't already done so and add the following
- <script>
$(document).ready(function() {// page is now ready, initialize the calendar...
$('#calendar').fullCalendar({
// put your options and callbacks here
})});
</script> - Add an element to a wordpress page or post where you would like the calendar to display with <div id='calendar'></div>
- Load the page, you should see a blank calendar. 🙂
- Create a view using the first form
- View Format should be 'All Entries'
- Add the following ( events: [ ) in the before content field, don't add brackets.
- In the content field add:
{
title : '[214]',
start : '[560 format="Y-m-d"]',
backgroundColor : '[558 show=787]',
url : '/equipment-inventory-overview/view-equipment-inventory/?entry=[id]'
}, - Add the fields you would like to use, also note the change of date to Y-m-d format!
- Note/copy the shortcode for adding the view in a template
- Go back to your snippet and add the shortcode like below
- <script>
$(document).ready(function() {// page is now ready, initialize the calendar...
$('#calendar').fullCalendar({
// put your options and callbacks here
<?php echo FrmProDisplaysController::get_shortcode( array( 'id' => 2171) ) ?>
})});
</script>
- Create a view for the second form
- View Format should be 'All Entries'
- In the content field add:
{
title : '[553]',
start : '[789 format="Y-m-d"]',
backgroundColor : '[787]',
url : '/vessel-systems-overview/view-vessel-systems/?entry=[id]'
}, - In the After Content field add a single square bracket }
- Note/copy the shortcode for adding the view in a template
- Go back to your snippet and add the shortcode behind the other shortcode you added in step 4-6 & 4-7 above
- Your code should now look like this..
<script>
$(document).ready(function() {// page is now ready, initialize the calendar...
$('#calendar').fullCalendar({
// put your options and callbacks here
<?php echo FrmProDisplaysController::get_shortcode( array( 'id' => 2171) ) ?><?php echo FrmProDisplaysController::get_shortcode( array( 'id' => 2187) ) ?>
})});
</script> - Go to your page and you should see entries added to the calendar! 🙂
- <script>
It looks like there are tons of customisation options with the fullCalendar plugin.
Hope it helps some others! 🙂
Regards
Matt
October 22, 2015 at 8:11 am
If anyone finds this useful and is able to understand how to add repeating events just as formidable does with its own native calendar view builder I'd be really grateful for any pointers!
October 22, 2015 at 8:18 am
Thinking out loud (well typing) could I amend the code from here at all
https://formidableforms.com/knowledgebase/frm_show_entry_dates/
October 22, 2015 at 12:09 pm
Thanks for the tip! This is really cool.
In Formidable, we create an array of the repeating events for the currently-viewed month, like this:
October 22, 2015 at 12:20 pm
Thanks Jamie!!
I will have a play with your code :-)
I've managed to get round it (well side stepping) by re-designing my form slightly by using a repeatable section and getting the user to add their service dates manually which gives the same result I was after.
Ideally a computed method would be better so I'll have a play and if I get it working will post amendment here :-)
Discussion closed.