• Resolved luelsdorffdplusb

    (@luelsdorffdplusb)


    Hey guys,

    I found (and customized) a code snippet to show the next few events on my front-page.php by using a loop. Now I’d like to show the location-div (“.termin_details_ort”) only if a location exists.

    I didn’t find a way to do that, any suggestions?

    NOTE: I’m not THAT familiar with PHP. 🙁

    <?php
       $events = EM_Events::get(array('limit'=>3, 'orderby'=>'event_start_date,event_start_time'));
       foreach ( $events as $event ) { ?>
       <div class="termin_teaser box third">
          <h3><?php echo $event->output('#_EVENTNAME'); ?></h3>
    
          <p class="termin_datum"><?php echo $event->output('#_EVENTDATES'); ?>, <?php echo $event->output('#_EVENTTIMES'); ?></p>
          <p class="termin_ort"><?php echo $event->output('#_LOCATIONTOWN'); ?>, <?php echo $event->output('#_LOCATIONCOUNTRY'); ?></p>
          <div class="termin_toggle">Mehr Details</div>
          <div class="termin_details green box">
             <div class="termin_meta">
                <h3><?php echo $event->output('#_EVENTNAME'); ?></h3>
                <div class="termin_details_datum"><p class="termin_details_datum"><?php echo $event->output('#_EVENTDATES'); ?>, <?php echo $event->output('#_EVENTTIMES'); ?></p></div>
    <!-- ##################################### show/hide following line ##################################### -->
                <p class="termin_details_ort"><?php echo $event->output('#_LOCATIONTOWN'); ?>, <?php echo $event->output('#_LOCATIONCOUNTRY'); ?></p>
    <!-- ##################################### show/hide line above ##################################### -->
                <p class="termin_details_beschreibung"><?php print $event->output('#_EVENTEXCERPT'); ?></p>
                <p class="termin_details_link"><a href="<?php print $event->output('#_ATT{termin_details_link}'); ?>" target="_blank">Details & Anmeldung ›</a></p>
             </div>
             <?php echo $event->output('#_EVENTIMAGE'); ?>
          </div>
       </div>
    
       <div class="clear"></div>
    
    <?php } ?>

    https://ww.wp.xz.cn/plugins/events-manager/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    sorry I’m afraid that we can’t help with regards to custom coding as per the support policy – http://eventsmanagerpro.com/support-policy/

    Thread Starter luelsdorffdplusb

    (@luelsdorffdplusb)

    Ok, maybe I didn’t formulate my question correctly.
    I thought showing the problem in application would be helpful.

    Another try:
    Is there a way to conditionally show or hide a field in a looped output which is not on the declared “events”-page?
    The conditional placeholders (e.g. {has_location}{/has_location}) enable this feature in the events-formatting, I’m pretty sure this can also be done in PHP.

    If it helps: I don’t need someone to write me the code, just a hint how to use an “If”-Loop to show and hide a field conditionally.

    Thanks in advance!

    Plugin Support angelo_nwl

    (@angelo_nwl)

    you can see this under events-manager/classes/em-event.php function output()

    Thread Starter luelsdorffdplusb

    (@luelsdorffdplusb)

    Thank you for that answer, I think that should do!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Conditional output in em_events::get() loop’ is closed to new replies.