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