Hiding Widget via shortcode

Home Forums Calendar Products Events Calendar PRO Hiding Widget via shortcode

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1013245
    David
    Participant

    I’m using the following to place a widget on my home page

    [tribe_events_list limit=”1″ category=”Home Page” Title=”Forthcoming Events”]

    This works great, but when there are no events it’s shows

    Forthcoming Events
    There are no upcoming events at this time.

    rather than showing nothing. How do I get the widget to autohide when empty ?

    #1013301
    George
    Participant

    Hey @David,

    You unfortunately couldn’t get this to show nothing without custom coding 🙁

    If you’re curious how to do that, you first need to find this plugin file:

    the-events-calendar/src/views/widgets/list-widget.php

    You will see the code there like this:

    esc_html__( 'There are no upcoming %s at this time.', 'the-events-calendar' )

    This is that text you want to remove; you can remove this whole block of code right from the original plugin file, or you can do the recommended approach of adding a duplicate version of this file in a new folder in your theme called /tribe-events. Then, you’d just remove the code from the duplicated version of the file, so that every time you update The Events Calendar in the future your customization will remain in place.

    If you’re interested in this second option I mentioned, learn more about it here in our official Themer’s Guide → https://theeventscalendar.com/knowledgebase/themers-guide/

    Regardless of method, the principle is the same: remove the text from that aforementioned list-widget.php file. That is unfortunately the only way at this time 🙁

    I hope this helps!

    — George

    #1013310
    David
    Participant

    Wouldn’t it be better to code up the “Hide this widget if there are no upcoming events” property to be available to the shortcode as well as the regular widget (which the docs say it supports) ?

    #1013588
    David
    Participant

    Where am I going wrong ?

    I created the folder structure

    /wp-content/themes/cake/tribe-events/pro/widgets/
    and copied in to there the file list-widget.php

    I then edited the appropriate line thus

    <p><?php printf( __( ‘COPY There are not any upcoming %s at this time.’

    (i.e I added the word COPY)

    I also (as a later test) edited the original file
    /wp-content/plugins/events-calendar-pro/src/views/pro/widgets/list-widget.php

    changing the line to

    <p><?php printf( __( ‘ORIGINAL There are not any upcoming %s at this time.’

    When I viewed the web page the ORIGINAL version is displayed rather than the COPY.

    #1013874
    George
    Participant

    Hey @David,

    I’m really sorry to hear this – I’m not sure why that template override isn’t working for you, I just tested on my own site and it worked fine. Here’s a screenshot of my exact directory structure, I’m using the twentytwelve theme:

    As for the shortcode and widget disparity, the shortcode actually just directly calls the widget instance; so with this in mind, then, does anything improve here if you just try adding no_upcoming_events=true to your shortcode? Like this e.g.:


    [tribe_events_list limit="1" category="Home Page" Title="Forthcoming Events" no_upcoming_events=true]

    #1014255
    David
    Participant

    I’m guessing it must be something in the theme then that’s stopping it. Have over written the widget for the time being.

    #1014491
    George
    Participant

    Sorry about the trouble here @David – not sure why your custom template files aren’t working correctly…

    For now I will close up this thread, but if these issues arise again open a new thread any time! Include a link back to this thread for context, if you think of it, and we’ll pick up where we left off.

    Sincerely,
    George

    #1019711
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Hiding Widget via shortcode’ is closed to new replies.