• i placed a shortcode to my page with upcomming events. What if this list is empty – am i able to not show the list? and not the comment “no events”

    For example is it possible to have a custom class on that case on those lists that are empty (em-events-list-empty)

Viewing 9 replies - 1 through 9 (of 9 total)
  • You can change the message from “No events” to some other message by going to Events Manager Settings and then click on the Fomatting tab and then click on Events and under the Events List format you can specify the “No events message”.

    Thread Starter Guenni007

    (@guenni007)

    the message is not the problem – wouldn’t it be better to set those empty lists to display: none ?

    somewhere in the code you must find the instruction to set this message. Then you could just as well add another class to the upper container (em-view-container), like em-list-empty – which you could then set to display : none yourself.
    Unfortunately I can’t find the place in the source code.

    Thread Starter Guenni007

    (@guenni007)

    or is there a conditional placeholder like: {has_event} ?

    then i could create my on format wraped by that placeholder …

    The function that outputs the event list is EM_Events::output defined in wp-content/plugins/events-manager/classes/em-events.php

    You’ll see the following code:

            if ( $events_count > 0 ) {
                ...
             }elseif( $args['no_results_msg'] !== false ){
               $output = !empty($args['no_results_msg']) ? $args['no_results_msg'] : get_option('dbem_no_events_message');
             }
             ...
            $output = apply_filters('em_events_output', $output, $events, $args);
            return $output;

    There is no placeholder like {has_event}

    You could use the ’em_events_output’ filter to override the output in the case when there were no events.

    You could also suppress the message using the no_results_msg setting in the shortcode:

    [events_list no_results_msg=" "]

    Or you could specify the following shortcode:

    [events_list no_results_msg='<div class="no-results-msg"></div>']

    And then add the following css:

    .no-results-msg {
        display: none;
    }
    • This reply was modified 1 year, 9 months ago by joneiseman.
    Thread Starter Guenni007

    (@guenni007)

    thanks – i found that code – but i prefer not to show any wrapping container. On templates i see this: events-list.php for example and:

    $args = apply_filters('em_content_events_args', $args);
    if( empty($args['id']) ) $args['id'] = rand(100, getrandmax()); // prevent warnings
    $id = esc_attr($args['id']);
    ?>
    <div class="<?php em_template_classes('view-container'); ?>" id="em-view-<?php echo $id; ?>" data-view="list">
    	<div class="<?php em_template_classes('events-list'); ?>" id="em-events-list-<?php echo $id; ?>" data-view-id="<?php echo $id; ?>">
    	<?php
    	echo EM_Events::output( $args );
    	?>
    	</div>
    </div>

    isn’t it possible to insert a class to the top div if there are no events?

    You could use the ’em_events_output’ filter to add a wrapping containter with a class to the “No events” message.

    Thread Starter Guenni007

    (@guenni007)

    Can you help me to use the filter that way – please?

    Add the following code snippet:

    add_filter( 'em_events_output', 'my_em_events_output', 10, 2 );
    function my_em_events_output( $output, $events )
    {
        if ( count( $events ) == 0 )
            return '<div class="em-no-events">' . $output . '</div>';
        else
            return $output;
    }
    

    You can use the Code Snippets plugin to add code snippets.

    Thread Starter Guenni007

    (@guenni007)

    Thats it – now i can go and set the upper parent to display none by jQuery. Thanks alot.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘events-list empty’ is closed to new replies.