Support

Home Forums Event Espresso Premium Events Grid View Template – All Event Dates

Events Grid View Template – All Event Dates

Posted: May 12, 2020 at 3:33 pm

Viewing 2 reply threads


getcookingedm

May 12, 2020 at 3:33 pm

Hi,
I have a relatively simple issue with the Grid View template that I’ve been unable to solve. One of my events has multiple dates, May 16 and May 17, however the grid view is only showing the first date. It would make the most sense if it was able to show both dates as their own grid item, and then linking to the same spot, I just don’t know how to accomplish it with the EE functions within the Grid View.

For reference, this is the code that is in the template file.


global $post;

//Create the event link
$external_url 		= $post->EE_Event->external_url();
$button_text		= !empty($external_url) ? $alt_button_text : $reg_button_text;
$registration_url 	= !empty($external_url) ? $post->EE_Event->external_url() : $post->EE_Event->get_permalink();
$feature_image_url	= $post->EE_Event->feature_image_url();

if(!isset($default_image) || $default_image == '') {
	$default_image = EE_GRID_TEMPLATE_URL .'/images/default.jpg';
}

$image = !empty($feature_image_url) ? $feature_image_url : $default_image;

$datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $post->ID, $show_expired, true, 1 );

$datetime = end( $datetimes );

if ($datetime instanceof EE_Datetime) {

$startdate = date_i18n( $date_format . ' ' . $time_format, strtotime( $datetime->start_date_and_time('Y-m-d', 'H:i:s') ) );
	?>
	<div class="ee_grid_box_v2 item admin-item">

		<img />" alt="" />
		<div onclick="" class="darken ee_overlay">

			<div class="event-title title"><?php echo $post->post_title; ?></div>
			<p class="start-date"><?php echo $startdate; ?></p>
			<p class="event-link"><?php echo '<a>ID .'" href="' . $registration_url . '">' . $button_text . '</a>'; ?></p>
		</div>
	</div>
<?php>

I’m pretty sure that it’s the standard template with some minor class changes.

I’ve tried making changes to the $datetimes pull, and creating other pulls, but every time I do, I crash the page.

Any help would be greatly appreciated.
Thanks!


Seth Shoultes

  • Support Staff

May 14, 2020 at 8:45 am

Hi there,

Sorry for the delay. It looks like you have some code issues with what you’ve shared here. For example, this line of your code: <img />" alt="" />
Should look like this: <img src="<?php echo $image; ?>" alt="" />

Then, this line of code is broken:
<p class="event-link"><?php echo '<a>ID .'" href="' . $registration_url . '">' . $button_text . '</a>'; ?></p>

It should look something like this:
<p class="event-link"><?php echo '<a href="'. $post->ID .'" ' . $registration_url . '">' . $button_text . '</a>'; ?></p>

Once those issues are fixed, try the code again and see if it’s working.


Tony

  • Support Staff

May 14, 2020 at 9:28 am

Further to the above, you can’t easily split individual datetimes within events into separate grid items but you can change the date output on the dried to be a range, would that work?

I’ve put together a template that shows how you can do the above here:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/addons/eea-events-grid-view-template/templates/espresso-grid-template-date-range.template.php

Viewing 2 reply threads

The support post ‘Events Grid View Template – All Event Dates’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso