Event-List-Widget multiple Templates

WordPress Event Management, Calendars & Registration Forums General Question Event-List-Widget multiple Templates

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 10 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #15305

    Hi,

    I’m using the widget-event-list.php template in my theme to show a customized list of events in my footer. However, now I need to show another list with more details on another part of the website. So I’d like to use widget-event-list_detailed.php for example. Unfortunately there seems to be no way to define the template file in the widget options. Is there any easy way to realize that?

    Thanks.

    Taufue
    #15348

    Hi Taufue,

    There is a template option, but this is not a particularly flexible way of defining the events.

    The template option is intended for placeholder tags, but it’s possible to abuse this by specifying a template file and using the following code:

    function my_eo_widget_template_hack( $template ){
        global $eo_event_loop_args;
    
        if( !empty( $eo_event_loop_args['template'] ) ){
            $template = $eo_event_loop_args['template']; 
        }
    
        return $template;
    }
    add_filter( 'eventorganiser_event_list_loop', 'my_eo_widget_template_hack' );
    

    Then just use the template widget option to specify a file name of the template (which should be in the root of your theme). Or leave blank for the default template.

    This a hack on two fronts though :). First, as mentioned, the template option is not intended for an intented template name, but placeholder tags. Secondly, the use of the global $eo_event_loops_args. This probably isn’t going away (at all), and I strive to maintain backwards compatibility, but it was never intended for this ;).

    That said, when this code is revisted I shall try to provide a better way of specifying a template file per widget. This was a scenario that I had thought might occur and it was only a matter of time before it did.

    • This reply was modified 10 years ago by  Stephen Harris. Reason: Corrected typo in code
    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.