Include venue details and Additional custom field in month/mobile.php

Home Forums Calendar Products Events Calendar PRO Include venue details and Additional custom field in month/mobile.php

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1171746
    Greig
    Participant

    Hi,

    I would like to include the venue details: Name, address, organised by and 1 additional field in the mobile.php file of the month view.

    Can you please provide the necessary code as it is written in javascript rather than php.

    Php code is:

    	<?php if ( $venue_details ) : ?>
    			<!-- Venue Display Info -->
    			<div class="tribe-events-venue-details">
    				<?php echo implode( ', ', $venue_details ); ?>
    				<p><?php $organisedby = tribe_get_custom_field('organisedby'); 
    					if (!empty($organisedby)) { echo $organisedby; } else {
    						echo 'Organised By'; 
    					}
    					
    					?>: <?php echo tribe_get_organizer(); ?></p>
    				
    			</div> <!-- .tribe-events-venue-details -->
    		<?php endif; ?>
    
    

    Thanks,

    • This topic was modified 7 years, 7 months ago by Greig.
    #1172153
    Cliff
    Member

    Hi Greig.

    Since it looks like you know how to code, I’ll provide a more technical answer:

    https://github.com/moderntribe/the-events-calendar/blob/4.2.7/src/views/month/mobile.php#L5 states:

    Please see single-event.php in this directory for detailed instructions on how to use and modify these templates.

    And here’s a link to all that documentation (pretty much that entire file): https://github.com/moderntribe/the-events-calendar/blob/4.2.7/src/views/month/single-event.php#L30-L192

    Please let me know if you have any follow-up questions on this topic.

    #1172167
    Greig
    Participant

    Hi Cliff,

    Thanks for your reply. I have been through the documentation and read all the information you have sent, but I cannot get my head around how to get the results I need, so I am stuck!

    Yes I can code, but I need to add multiple fields to the page and I do not understand how to do that. Can you help with that?

    I understand to add the venue I add the follwing to the single-event.php

    $venue = array();
    $getvenue = tribe_get_venue();
    $venue['venue'] = $getvenue;
    

    I add this to the output:

    data-tribejson='<?php echo esc_attr( tribe_events_template_data( $post, $venue ) ); ?>'

    But I need to add multiple fields to the output, so could you please give an example of how to do that?

    Thanks,

    #1173367
    Cliff
    Member

    No problem.

    1)

    From your code:

    $venue = array();
    $getvenue = tribe_get_venue();
    $venue['venue'] = $getvenue;

    Replace $venue with $additional_data, just for best practices, since only 1 additional data variable/attribute can be passed through tribe_events_template_data().

    Therefore, you’ll end up with this instead (also shortened for simplicity’s sake):

    $additional_data = array();
    $additional_data['venue'] = tribe_get_venue();

    2)

    Copy /wp-content/plugins/the-events-calendar/src/views/month/single-event.php to /wp-content/themes/YOUR-CHILD-THEME/tribe-events/month/single-event.php

    Then edit Line 95 of your child theme’s single-event.php file to replace tribe_events_template_data( $post ) with tribe_events_template_data( $post, $additional_data )

    Now add your code to your child theme’s single-event.php file, above where the <div starts (and before the closing PHP ?>)

    3)

    Now copy /wp-content/plugins/the-events-calendar/src/views/month/mobile.php to /wp-content/themes/YOUR-CHILD-THEME/tribe-events/month/mobile.php

    Copy Lines 34-36 and paste it where you want your Venue information to display, for example, as the new Line 37.

    Then replace the IF’s excerpt.length with venue.length and create your output. Note: I’d recommend escaping the output by replacing [[=raw with [[=

    For example, this would be your new Lines 37-39:

     [[ if(venue.length) { ]]
    <div class="tribe-event-venue">[[= venue]]</div>
    [[ } ]]

    4)

    For your if ( $venue_details )… code from your initial post, you would insert additional array items into $additional_data in single-event.php

    For example:

    $additional_data = array();
    $additional_data['venue'] = tribe_get_venue();

    Now becomes:

    $additional_data = array();
    $additional_data['venue'] = tribe_get_venue();
    $additional_data['organizer'] = $organisedby;

    Then, follow along step 3 again to add ‘organizer’ output to your mobile.php file.

    I hope this gets the job done for you!

    #1184472
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Include venue details and Additional custom field in month/mobile.php’ is closed to new replies.