Support

Home Forums Event Espresso Premium Event Calendar Missing

Event Calendar Missing

Posted: July 23, 2018 at 11:32 am

Viewing 25 reply threads


cmccreery

July 23, 2018 at 11:32 am

The event calendar is missing from our site both on our custom page and the default /events page. Seeing an error in the console but not sure what it’s from.

wecm.ca/training-events/

https://d.pr/free/i/k0fRb9


Josh

  • Support Staff

July 23, 2018 at 11:43 am

Hi,

May I ask, is the Calendar shortcode added to the page content within the native WordPress editor? or added via a 3rd page builder editor? or added directly in with a do_shortcode() function to the template? If the latter, you’ll need to follow this guide:

https://eventespresso.com/wiki/events-calendar-add-on/#ee4customizations


cmccreery

July 23, 2018 at 1:28 pm

On the default /events page it’s just a short code. The other custome page I’m not sure.


Josh

  • Support Staff

July 23, 2018 at 1:53 pm

OK. In the page source, there’s a potential gotcha happening:

https://slack-files.com/T02SY781D-FBVFR1Q82-563fe7954c

Can you change the line:
jQuery('.expander').simpleexpand();

to be:

jQuery('.expander').SimpleExpand();

It looks like that’s something added from the theme.


cmccreery

July 23, 2018 at 2:47 pm

Changed that but still generating the same error.

https://d.pr/free/i/S9ueXc


Josh

  • Support Staff

July 23, 2018 at 3:10 pm

Yeah that was really bad advice on my part, debugging other people’s jQuery plugins is not exactly my wheelhouse. What happens if you remove the

<script type="text/javascript">
    jQuery(function () {
	jQuery('.expander').SimpleExpand();
    });
</script>

entirely? Does the calendar display then?


cmccreery

July 23, 2018 at 3:14 pm

Then I get a new error also related to jquery

https://d.pr/free/i/wENT2k


cmccreery

July 23, 2018 at 3:17 pm

I removed everything that was related in the header.php to those errors

<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery.resizeimagetoparent.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/simple-expand.js"></script>
<script type="text/javascript">
    jQuery(function () {
	jQuery('.expander').simpleexpand();
    });
</script>
<!-- sticky  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.sticky.js"></script>

<script>

	jQuery(function () {
		jQuery('#navMobileButton').click(function() {
			jQuery("#navMobile").toggleClass("show");
			jQuery("#mobileBlocker").toggleClass("expanded");
		});
    });
	jQuery(function () {
		jQuery('#mobileBlocker').click(function() {
			jQuery(this).toggleClass("expanded");
			jQuery("#navMobile").toggleClass("show");
		});
    });
    jQuery(function () {
	jQuery('#navTopSearch').click(function() {
		jQuery("#searchForm3").toggleClass("show");		
	});
    });
</script>

<script>
    jQuery(function () {
		jQuery('.fillParent').resizeToParent();
		jQuery('.fillParent2').resizeToParent({parent: '.childPages li a'});
		
	});
</script>

Now the calendar works properly.

http://wecmca.staging.wpengine.com/training-events/


cmccreery

July 23, 2018 at 3:25 pm

Homepage is also showing some errors around jquery as well.

https://d.pr/free/i/qAstG


Josh

  • Support Staff

July 23, 2018 at 4:25 pm

Is the area of the home page where the calendar would display set up using a page builder style editor or is it using the native WordPress editor?

With regards to those scripts, the way forward will be to use the wp_enqueue_script() function and load the scripts only where needed (and quite possibly set to load in the footer) instead of hardcoding them directly into header.php.


cmccreery

July 23, 2018 at 4:28 pm

Can you fix this with the support token service?

I tried changing the jquery( to $( and then it just says $ is not a function


Josh

  • Support Staff

July 23, 2018 at 4:48 pm

May I ask fix what exactly? Do you mean fix the jQuery plugins that are throwing JS errors or fix the home page so it can display the calendar?


cmccreery

July 23, 2018 at 4:52 pm

Think I found the cause. I replaced the following
`jQuery(function () {
jQuery(‘.expander’).simpleexpand();
});`

AND

 jQuery(function () {
  jQuery('.fillParent').resizeToParent();
  jQuery('.fillParent2').resizeToParent({parent: '.childPages li a'})
});

Replaced with:

`jQuery(function ($) {
$(‘.expander’).simpleexpand();
});`

AND

 jQuery(function ($) {
  $('.fillParent').resizeToParent();
  $('.fillParent2').resizeToParent({parent: '.childPages li a'})	
	});

I just have this error on the homepage now but I’m not actually loading the calendar here.

Uncaught ReferenceError: eeCAL is not defined


Josh

  • Support Staff

July 23, 2018 at 4:55 pm

Is the area of the home page where the calendar would display set up using a page builder style editor or is it using the native WordPress editor?


cmccreery

July 23, 2018 at 5:21 pm

That error is showing on all pages and I found this in the theme header.php.

<?php // needed to check for event espresso page
if ( class_exists( 'EED_Espresso_Calendar' ) ) {
	global $is_espresso_calendar;
	$is_espresso_calendar = TRUE;
	add_action( 'wp_enqueue_scripts', array( EED_Espresso_Calendar::instance(), 'calendar_scripts' ) );
	if ( EED_Espresso_Calendar::instance()->config()->tooltip->show ) {
		add_filter('FHEE_load_qtip', '__return_true' );
	}
} ?>

Should that be replaced with https://gist.github.com/joshfeck/5d9c88fea504c0b111c3df8f24ad25d9


Josh

  • Support Staff

July 23, 2018 at 5:57 pm

The above code should be removed from header.php.

Then you add the code from the gist to the theme’s functions.php file (or into a plugin).

Then change line 7 from the gist,
if ( class_exists( 'EED_Espresso_Calendar' ) && is_page( 'calendar' ) ) {

to match your home page. Which might be this:
if ( class_exists( 'EED_Espresso_Calendar' ) && is_home() ) {

or could be:
if ( class_exists( 'EED_Espresso_Calendar' ) && is_front_page() ) {


cmccreery

July 23, 2018 at 6:18 pm

Ok and if I wanted it to load those on both “events” and “training-events”

is_page( array(‘events’,’training-events’))


Josh

  • Support Staff

July 23, 2018 at 6:24 pm

I don’t think you need to force load the calendar scripts on the training-events page. is_page() does support an array though:

https://developer.wordpress.org/reference/functions/is_page/#comment-1031


cmccreery

July 23, 2018 at 6:26 pm

Those are the two pages that the calendars display on though


Josh

  • Support Staff

July 23, 2018 at 6:30 pm

The calendar is already displaying on training-events so why do you need to load the scripts again?


cmccreery

July 23, 2018 at 6:35 pm

Because those lines that I removed from the header were loading it on the training-events page. I removed those and added the code you said to the functions.php. If I remove it from functions then the calendar doesn’t load. Nor does it load on the /events page


Josh

  • Support Staff

July 23, 2018 at 7:07 pm

OK then. You’ll add whatever pages to your array, and if you’re also loading on a calendar on the home page, you can also include 1598 in the array.

e.g.

is_page( array( 1598, 'training-events', 'events' ) );


cmccreery

July 23, 2018 at 7:08 pm

Great! Thanks Josh!


cmccreery

July 23, 2018 at 9:46 pm

Almost, how do I target the default /events for EE4 as it doesn’t seem to work using the array. Is that because that page is considered an archive post type and not an actual page?


Josh

  • Support Staff

July 24, 2018 at 10:09 am

That’s right, it’s not a page if it’s a post type archive.

You can add to your conditional statement:

is_page( array( 1598, 'training-events' ) ) || is_post_type_archive( 'espresso_events' )

and you’ll need to account for operator precedence, so:

if ( class_exists( 'EED_Espresso_Calendar' ) && (
  is_page( array( 1598, 'training-events' ) ) 
  || is_post_type_archive( 'espresso_events' )
) ) {


cmccreery

July 24, 2018 at 3:14 pm

Great, thanks again!

Viewing 25 reply threads

The support post ‘Event Calendar Missing’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso