Hi @whiterat ,
Thank you for reaching out.
Unfortunately, I have not been able to reproduce the issue on my testing environment (screenshot link below). Could you provide more information about this, especially on how to reproduce it?
https://go.screenpal.com/watch/cZQb6QVSjz7
Hi!
Thank you for looking into this. I did some testing myself and would like to correct what I said before. It appears that I should have been more thorough in my reporting, since the current description is indeed a bit misleading & vague.
The function passed to add_action runs regardless of whether one is looking at the current month with or without events. However, my actual code doesn’t match the example 1:1, and this is where the problem seems to be.
Here’s what I’m using
add_action(
'tribe_template_before_include:events/v2/components/events-bar/views',
function ( $file, $name, $template ) {
$template->template( 'components/contact' );
},
10,
3
);
Like I said, this seems to run just fine. However, I put some “deadly” php into the contact.php template for testing, and that’s when things started to make more sense. Looking at the current month without any events does not cause the code to be executed for some reason.
Looking at your screenshot I noticed that you have other views (list, day) enabled. I only have month, although I doubt it makes a difference.
Let me know if I can be of more help or if you’ve managed to catch whatever obvious mistake I may be making here 🙂
Hi @whiterat ,
Thank you for your message and the clarification.
I can see that you are adding your own template file. But, I am not sure what you’ve placed in your contact.php file, so I tried to reproduce this with the following code in the components/contact.php file.
<?php
echo '<div><a href="#" style="line-height:60px; margin-left:22px;">Contact Us</a></div>';
With the above in place, I am using the following action filter snippet to call the template.
add_action( 'tribe_template_before_include:events/v2/components/events-bar/views', function( $file, $name, $template ) {
$template->template( 'components/contact' );
}, 10, 3 );
I also removed the list and day views to match what you have, and the following video recording is the result: https://somup.com/cZQF17mCoU.
In that regards, I am quite convinced the issue is coming from what you have in your components/contact.php file. But, I would like to note here that, while we do not discourage template customization, such endeavor requires extensive knowledge in WordPress/Web programming, and we, the support team, are not equipped with such command. — Please see our scope of support page.
Hi!
The contents of my contact.php are about as simple as what you used for testing. Just some html + very basic js. But I’m not even sure that’s relevant, given the “deadly” example I mentioned before. What made me curious was that when I added the aforementioned “deadly” die() to the beginning of contact.php, I could clearly see that the current month view without any events did not “die”, while other views (other months without or with events) did (which was, of course, what I expected).
Truth to be told, I’m not sure what to make of all this at the moment. I watched the video and saw no problems. I’ll try and dig a bit deeper next week at the latest. I have solved my initial problem by choosing a different approach, so this here needn’t be considered a support request per se, but it’d be good to figure out what’s going on.
Hi @whiterat ,
Thank you for your message and the information.
Based on your description, it sounds to me that it is related to caching. The Events Calendar month view is cached-enabled by default. So, I would suggest you try turning it off by deactivating Enable the Month View Cache in Events -> Settings -> General (tab) -> Viewing (section), and see if that alleviates your situation.
Plugin Support
Darian
(@d0153)
Hi @whiterat
I hope you’re doing well. I just wanted to touch base and check in with you. It’s been a little while since we’ve heard from you. I was just curious if you had the chance to try out the recommendation provided above.
Let me know if there’s anything I can assist you with.
Thanks for reaching out. The idea of disabling the cache is good, but that’s not the culprit as I’ve had it disabled for a while now (i.e before I started this thread). I have not had the time to do further testing yet, hence the delay in replying. I’ll try and report new details next week, after I’ve studied the problem a bit more.
Hi @whiterat ,
Thank you for your message and for your confirmation about the month view cache being not the culprit.
Feel free to let us know of any further details you may have about this issue.
Plugin Support
Darian
(@d0153)
Hi there,
It seems like this thread has been quiet for a bit, so we’ll go ahead and close it. However, if any further questions or concerns come up, please don’t hesitate to reply or start a new thread.