• Resolved mat8iou

    (@mat8iou)


    I am using the Event Calendar plugin to display up coming events in the sidebar of my blog. The thing is that a lot of the time, there aren’t any up-coming events, so I don’t really want a box near the top of my sidebar saying “No events” – I’d prefer if it just disappeared in these circumstances.

    Anyway, I searched the plugin documentation & found no obvious solution for this – so ended up creating some PHP code to capture the output & show the output conditionally depending on what it contained.

    <?php ob_start(); ?>
     <?php ec3_get_events(5); ?>
     <?php $events_list = ob_get_contents(); ?>
    <?php ob_end_clean(); ?>
    <?php if (!strstr($events_list,'No events')) : ?>
     <li class="events">
      <h2>Upcoming Events</h2>
       <ul>
        <?php echo $events_list; ?>
       </ul>
      </li>
    <?php endif; ?>

    The question is – is this a sensible way of doing what I’m trying to achieve? Or is there a more obvious way that I’m missing?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Is there a better way of doing this? (conditional use of Event Calendar plugin)’ is closed to new replies.