• Resolved whiterat

    (@whiterat)


    Hi!

    I came across the guide at https://theeventscalendar.com/knowledgebase/template-hooks/

    What caught my attention was the last example described there:

    add_action( 'tribe_template_before_include:events/v2/components/events-bar/views', function( $file, $name, $template ) {
    echo '<a href="#">My Link</a>';
    }, 10, 3 );

    This works, but there appears to be a catch (not sure I’d dare call it a bug just yet, may well be the intended behaviour). It appears that the function does not run if one is looking at the current month that has no events. However, if to use the datepicker and navigate to a month that has no events, it runs just fine. It also works with the current month, if there are events in it. In my case, month is the only view used.

    I’ve tried hooking to other templates as well. No luck. Where to hook to have the code run at all times (i.e with or without events in the view)?

    Thanks in advance

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support tristan083

    (@tristan083)

    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

    Thread Starter whiterat

    (@whiterat)

    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 ??

    Plugin Support tristan083

    (@tristan083)

    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.

    Thread Starter whiterat

    (@whiterat)

    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.

    Plugin Support tristan083

    (@tristan083)

    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.

    Thread Starter whiterat

    (@whiterat)

    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.

    Plugin Support tristan083

    (@tristan083)

    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.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.