• Resolved marcin1333

    (@marcin1333)


    I need to change one message generated by the calendar to another, I mean the message “There are no upcoming events.”. I tried with the below JS, but it didn’t work. Please help – how can I change the content of this message?

    document.addEventListener("DOMContentLoaded", function () {
    const updateEventMessage = () => {
    const noEventsMessage = document.querySelector(
    ".tribe-events-c-messages__message-list-item[data-key='0']"
    );

    if (noEventsMessage && noEventsMessage.textContent.trim() === "There are no upcoming events.") {
    noEventsMessage.textContent = "My NEW text.";
    }
    };

    const observer = new MutationObserver(function (mutationsList) {
    mutationsList.forEach(function (mutation) {
    if (mutation.type === "childList") {
    updateEventMessage();
    }
    });
    });

    const targetNode = document.querySelector(".tribe-events-c-messages__message-list");
    if (targetNode) {
    observer.observe(targetNode, {
    childList: true,
    subtree: true
    });
    }

    updateEventMessage();
    });
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support tristan083

    (@tristan083)

    Hi @marcin1333 ,

    Thank you for reaching out.

    Kindly try the following custom snippet which you can add to your theme’s functions.php file or through a Code Snippets plugin.

    add_filter ( 'tribe_events_views_v2_view_messages', function ( $messages ) {
    if (isset($messages['notice'])) {
    $index = array_search ( 'There are no upcoming events.', $messages['notice'], true );
    }
    if (isset($index) && $index !== false) {
    $messages['notice'][$index] = 'More events coming soon!'; // Your custom message
    }
    return $messages;
    });
    Thread Starter marcin1333

    (@marcin1333)

    Thank you very much for your help. You solved my problem bro ??

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