• Resolved eb29

    (@eb29)


    Hello there,

    I am currently creating a website for a museum network with Events Manager.
    Each museum has its own ‘Location’ page made with a specific template.
    In each ‘Location’ page, I want to show the list of upcoming events for this location.
    I searched everywhere but in vain (or so I missed something): what is the function and filters (to paste in my template) that displays the upcoming events for each location? (Php)

    Thank you for your help!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi Eb,
    EM user here too. ??

    Just to make sure that we’re on the same ‘page’. ??
    When you say “has its own ‘Location’ page”, I hope you do mean that each museum is created as an EM location right? Because then you keep all benefits of EM connecting everything. If not, then you would be re-creating EM basics.

    If not, then you would need to create the EM Locations anyway. Each Museum page will then have its own Location Page (and location ID, which is what you will want to use). Then you can “trick” your website into using EM data on non-EM pages, but you would aways have to refer back to the EM Location ID in some way.

    For now, I will go with “no, the museums are not EM Locations”.
    Then, do create an EM location for each museum. That will help you with maps, events, etc. etc.
    Then in the custom template you can link back to the EM Location ID. Listing upcoming events can than be done with [location post_id=”XXX”] <your markup> [/location].

    Again, creating your museums as “normal” EM Locations would save a lot of hassle and make EM much easier to use. ??

    I think it would be easier to create a single-location.php and within that code conditions for loading specific templates per museum. That way you could still use the basics of EM and have custom templates per museum as well.

    Perhaps something along this line?

    $loc_id = $EM_Location->_location_id;
    if( $loc_id === '1' ) { //load template museum #1 }
    elseif( $loc_id === '2') { Load template #2 }

    etc.

    Thread Starter eb29

    (@eb29)

    Hello Patrick and thank you for your reply !

    I actually used the ‘EM Locations’ to create each museum page.
    When the site will be officially online, this museum network will intend to grow and the future webmaster of the site will have to add a new ‘EM Location’ page each time a new member will join the network.
    However, since it is impossible to know how many new museums will join the network, the code for displaying museum events is located in the Location template page. (can’t use a shortcode in each page)
    So I need the php function that calls the event list associated with each location, new or old, in my template.
    I can not use your code because it would mean adding a line of code to each new location … to infinity.

    Another idea maybe?

    Thread Starter eb29

    (@eb29)

    And I forgot : I have only one template for all the locations…
    Thank you by advance !

    Hi Eb,

    Thanks for your extensive reply. But actually it just confused me even more. It sounds like what you want is the core feature of EM Locations! ??

    In the single location page the webmaster can put any info of each separate museum. EM automatically adds anything under that content with what you have set in Events -> Settings -> Formatting -> Locations -> Single Location Page -> Single location page format. The placeholder #_LOCATIONNEXTEVENTS will automatically display all upcoming events for that particular, single location/museum.

    Anything you put there, would be the exact equivalent of php coding in the template file:
    $EM_Location->output("#_LOCATIONNEXTEVENTS");

    What you seem t want to do is exactly what that built-in option already does. ??

    Anything you hard-code into the template file, will have the same layout for each location. And that is just what that section in the settings does also. You can format the lay-out and the placeholders will make sure the displayed info is only related to that single location.

    Thread Starter eb29

    (@eb29)

    Indeed, you must be right … So what would be the complete code to display in my template for my site page?
    $EM_Location->output("#_LOCATIONNEXTEVENTS"); doesn’t work…
    I tried `if (class_exists(‘EM_Events’)) {
    echo EM_Events::output( array(‘limit’=>10,’orderby’=>’name’) );
    }` but the list shows all the events and not only those of the location.
    Thank you by advance !

    • This reply was modified 6 years, 4 months ago by eb29.

    First of all, that’s because you are using Events instead of Event.

    Maybe this will work:

    global $EM_Event;
    $EM_Location = $EM_Event->get_location();
    echo $EM_Location->output("#_LOCATIONNEXTEVENTS");
    

    Again, I wonder why your insist on getting this default info from outside of the loop. It is MUCH MUCH MUCH easier to d this from a Location page!!!

    Thread Starter eb29

    (@eb29)

    Hello Patrick,
    I still think I can not make myself understood.
    Again, I only have one page template for all my placements.
    So what I want is not to get out of the loop but to insert elsewhere in the page, and not in “the_content” the list of events of the location (what does the Events Manager plugin do in the configuration options ).
    I have created tabs with the address, the practical information of the site, and I would like to see in this block the list of events of the location.

    Unfortunately your code does not work … I hope I was explicit enough this time and you can help me!

    This is my code in /content-emplacement.php :

    <?php 
    /** Vérifier l'activation de ACF
    */
    if ( !function_exists('get_field') ) return;
    ?>
    
    <div id="tabs">
      <div class="tab"><input id="tab-1" type="radio" checked="checked" name="tab-group-1" />
        <label for="tab-1">Adresse</label>
          <div class="contenu">
    		  
    		 <?php if( get_field('adresse') ): ?>  <?php the_field('adresse'); ?><br/><?php endif; ?>
    		  
     <?php if( get_field('code-postal') ): ?><?php the_field('code-postal'); ?><?php endif; ?> 
    	<?php if( get_field('ville') ): ?>	  <?php the_field('ville'); ?><br/><br/><?php endif; ?> 
    <?php if( get_field('numero_tel') ): ?> <?php the_field('numero_tel'); ?><br/><br/><?php endif; ?> 
    	<?php if( get_field('adresse_mail') ): ?>	  <a href="mailto:<?php the_field('adresse_mail'); ?>"><?php the_field('adresse_mail'); ?></a><br/><br/><?php endif; ?>
    <?php if( get_field('site_web') ): ?><a href="<?php the_field('site_web'); ?>"><?php the_field('site_web'); ?></a><br/><?php endif; ?>
    		  <?php if( get_field('lien_carte') ): ?>
      <?php the_field('lien_carte'); ?><br/>
    <?php endif; ?>
          </div>
      </div>
    	
    	<?php if( get_field('infos-pratiques_check') == 'oui' ): ?>
    	<div class="tab"><input id="tab-2" type="radio" name="tab-group-1" />
        <label for="tab-2">Informations pratiques</label>
          <div class="contenu">
    		  <?php if( get_field('horaires') ): ?>
    <h4> Horaires : </h4><?php the_field('horaires'); ?><br/>
    <?php endif; ?>
    		  <?php if( get_field('tarifs') ): ?>
      <h4>Tarifs : </h4><?php the_field('tarifs'); ?>
    <?php endif; ?>  
          </div>
      </div>
     <?php endif; ?>
    	
    	<div class="tab"><input id="tab-3" type="radio" name="tab-group-1" />
    		 <label for="tab-3">événements</label>
    		<div class="contenu">
    
    -----------------HERE IS WHERE I WANT To INSERT THE EVENT LIST-----------------
      
    		</div>
    	</div>
    </div>
    <? php the_content(); ?>

    Thank you again by advance !
    ?? `

    • This reply was modified 6 years, 4 months ago by eb29.

    Hi Eb,

    I am sorry, but this goes far beyond the scope of a/this free support forum, even for me. What you need is highly customized coding. You’d best hire a developer for that with access to your server and files.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Upcoming events of a specific location’ is closed to new replies.