Modify Widget Text When No Upcoming Events

Home Forums Calendar Products Events Calendar PRO Modify Widget Text When No Upcoming Events

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #113061
    Sonya Mowery
    Participant

    I want to slightly change the text that appears in the widget when there are no upcoming events. I want to be able to point users to past events with a link. I’m sure I could poke around and modify the plugin but my concern is that any changes I make will be overwritten with updates to the plugin. What is the best way to approach this?

    #113325
    Barry
    Member

    Template overrides!

    Whether your theme is a likely to be subject to updates from an external source of not (such as if you bought one or sourced one from wordpress.org and will be keeping it updated) will dictate where exactly you place the overrides – you might place them in a child theme for instance – but in general, that’s the way to go.

    Please see: Themer’s Guide.

    I hope that helps!

    #113407
    Sonya Mowery
    Participant

    It appears though this message is created through the events-list-widget.class.php file not a view file.

    #115770
    Sonya Mowery
    Participant

    So how do you handle overrides for .class.php files? See my post above.

    #115844
    Barry
    Member

    Hi!

    If the text you wish to modify is in the widget class itself, then there are a few options open to you:

    • If you don’t wish to replace the text, but instead want to add to it, you could leverage the tribe_events_after_list_widget action hook to do so
    • The there are no upcoming events at this time message is translatable – so setting up a custom translation for that string is another possibility, as is leveraging the gettext filter hook
    • You could define a new class inheriting from the existing one defined in our plugin, change only what you need to change in the child class, and register it as a new widget

    So there are different ways to tackle it (you could also add and make use of output buffering via various other actions and modify the result) and the best approach is really going to depend on what you are most comfortable with.

    I hope that helps!

    #116155
    Sonya Mowery
    Participant

    Thanks for the response Barry! Yes I feel confident I can take it from here.

    #138339
    Barry
    Member

    Closing this thread as it’s been quite a while – of course if we can help with anything else please do create a new thread. Thanks!

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Modify Widget Text When No Upcoming Events’ is closed to new replies.