Support » Plugin: Events Manager » [Plugin: Events Manager] problem with conditional placeholder at EM

  • hi ,

    i have a problem with displaying content by conditional placeholder in the single-event.php

    i am creating a program for a cinema with recurring movies, and the employees will administrate all…but they need it as simple as possible…

    they want me to show further recurring dates on the detail page of an recurring event…so i think that could be the best way

    they don`t know shortcodes or wordpress at all…so i try to automate it

    first i created the placeholder #_RECURRENCEID from the recurrence_id in the wp_event_options table with a hook
    and a conditional placeholder…{has_recurrence}

    everything works fine in the override formats mode:

    [93 lines of code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    http://wordpress.org/extend/plugins/events-manager/

Viewing 10 replies - 1 through 10 (of 10 total)
  • can you post the code snippet again and a sample end result or objective if possible?

    ok i will..but i am working on localhost..right now just for testing…so i can attache 1-2 images

    here the code for the override mode…that works:

    {has_recurrence}
    [events_list recurrence="#_RECURRENCEID" #_EVENTLINK – Dates : #_EVENTDATES, Times : #_EVENTTIMES][/events_list]
    {/has_recurrence}

    and the codefor the conditional placeholder {has_recurrence}

    //condition:has_recurrence
    
    add_action('em_event_output_condition', 'my_em_styles_event_output_condition', 1, 4);
    function my_em_styles_event_output_condition($replacement, $condition, $match, $EM_Event){
        if( is_object($EM_Event) && preg_match('/^has_recurrence$/',$condition, $matches) ){
            if( $EM_Event->is_recurrence() ){
                $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
            }else{
                $replacement = '';
            }
        }
        return $replacement;
    }

    here the code in the single-event.php:

    <?php get_header(); ?>
    <div id="primary">
    	<div id="content" role="main">
    		<?php
    			global $post;
    
    			$EM_Event = em_get_event($post->ID, 'post_id');
    		?>
    
    		<header class="entry-header">
    		<h1 class="entry-title"><?php echo $EM_Event->output('#_EVENTNAME'); ?></h1>
    		</header>
    
    		<div class="entry-content">
    		<p><?php echo $EM_Event->output('
    
    		#_ATT{Credits}
    <p>
    
    	#_EVENTDATES<br /><i>#_EVENTTIMES</i>
    </p>
    {has_location}
    <p>
    	<strong>Location</strong><br/>
    	#_LOCATIONLINK
    </p>
    {/has_location}
    <p>
    	<strong>Category(ies)</strong>
    	#_CATEGORIES
    </p>
    <br style="clear:both" />
    <a href="#_EVENTIMAGEURL" rel="lightbox[]"><img src="#_EVENTIMAGEURL"></a>
    #_EVENTNOTES
    #_EVENTGCALLINK
    <br>
    #_RECURRENCEID
    <br>
    
    {has_bookings}
    <h3>Bookings</h3>
    #_BOOKINGFORM
    {/has_bookings}
    Website:<a href="#_ATT{website}" target="_blank">#_ATT{website}</a>
    <br>
    Promoter:<a href="#_ATT{promoter}" target="_blank">#_ATT{promoter}</a>
    ');
    //recurring dates
    
    $recurr_id = $EM_Event->recurrence_id;
    
    if (class_exists('EM_Events')) {
    	echo EM_Events::output(array('recurrence'=>$recurr_id, 'orderby'=>'event_start_date', 'limit'=>5, 'pagination'=>1, 'format'=>'
    
    {has_recurrence}
    	#_ATT{Credits}
    <p>
    <a href="#_EVENTURL">#_EVENTNAME</a>
    <br>
    #_EVENTDATES<br /><i>#_EVENTTIMES</i>
    </p>
    {/has_recurrence}
    
    {has_location}
    <p>
    	<strong>Location</strong><br/>
    	#_LOCATIONLINK
    </p>
    {/has_location}
    '
    ));
    }
     ?>
           </p>
    		</div>
    
    	</div><!-- #content -->
    </div><!-- #primary -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    here 2 links to the result images

    one with a recurring event and one with a single event

    i have to use it without override formats cause of wp-touch pro

    here the rest of my problem description

    in the single-event.php the most things work too except {has_recurrence}
    i see all recurring dates of an event in the details view
    but if an event is not recurring there`s no recurrence_id and i see the dates of all recurring events

    i use $EM_Event->output for the usual data
    for the recurring dates list i use an EM_Events::output array

    there {has_recurrence} doesn`t work anymore
    but e.g. {has_location}

    here the code for the recurence_id placeholder #_RECURRENCEID …if needed:

    //recurrence id placeholder
    
    add_filter('em_event_output_placeholder','recurrence_placeholders',1,3);
    	function recurrence_placeholders($replace, $EM_Event, $result){
     global $wp_query, $wp_rewrite;
     switch( $result ){
      case '#_RECURRENCEID':
          $replace = $EM_Event->recurrence_id;
      break;
     }
     return $replace;
    }

    i resolved it on this way…it works nice

    //recurring dates
    
    $no_events = "no recurring events";
    
    $recurr_id = $EM_Event->recurrence_id;
    
    if ($recurr_id == NULL) {
    	echo $no_events;
    	}
    elseif 	($recurr_id != NULL){
    
    if (class_exists('EM_Events')) {
    	echo EM_Events::output(array('recurrence'=>$recurr_id, 'orderby'=>'event_start_date', 'limit'=>5, 'pagination'=>1, 'format'=>'
    
    	#_ATT{Credits}
    <p>
    <a href="#_EVENTURL">#_EVENTNAME</a>
    <br>
    #_EVENTDATES<br /><i>#_EVENTTIMES</i>
    </p>
    
    '
    ));
    }}

    thx for updating.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: Events Manager] problem with conditional placeholder at EM’ is closed to new replies.