Skip to content

Commit

Permalink
Merge pull request #23 from aydun/eventListingTweaks
Browse files Browse the repository at this point in the history
Event listing tweaks
  • Loading branch information
agileware-justin authored May 27, 2022
2 parents eddeed2 + 514b886 commit 44f2004
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions shortcodes/event/event-listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function shortcode_callback($atts = [], $content = NULL, $tag = '') {

try {
$results = \Civi\Api4\Event::get()
->addSelect('id', 'title', 'start_date', 'end_date', 'event_tz', 'event_type_id', 'is_online_registration')
->addSelect('id', 'title', 'start_date', 'end_date', 'event_tz', 'event_type_id', 'is_online_registration', 'summary', 'registration_link_text')
->addWhere('start_date', '>=', 'today')
->addWhere('is_public', '=', TRUE)
->addWhere('is_active', '=', TRUE)
Expand Down Expand Up @@ -98,21 +98,23 @@ private function get_event_item_html(array $event) {

$end_date_text .= ' ' . (!empty($event['event_tz']) ? $event['event_tz'] : CRM_Core_Config::singleton()->userSystem->getTimeZoneString());

$output = '<div class="civicrm-event-listing-item"><h3 class="civicrm-event-item-header">' . $this->get_event_info_link_html($event['id'], $event['title']) . '</h3><p class="civicrm-event-item-date">' . $start_date_text . $end_date_text . '</p>';
$output = '<div class="civicrm-event-listing-item"><h3 class="civicrm-event-item-header">' . $this->get_event_info_link_html($event['id'], $event['title']) . '</h3>' .
'<p class="civicrm-event-item-date">' . $start_date_text . $end_date_text . '</p>' .
'<p class="civicrm-event-item-summary">' . $event['summary'] . '</p>';

// If on-line registration is enabled display the register now link
if ($event['is_online_registration']) {
$output .= '<p class="civicrm-event-item-register">' . $this->get_event_register_link_html($event['id'], 'Register now') . '</p>';
$output .= '<p class="civicrm-event-item-register">' . $this->get_event_register_link_html($event['id'], $event['registration_link_text']) . '</p>';
}
$output .= '</div>';

return $output;
}

private function get_event_register_link_html(string $event_id) {
private function get_event_register_link_html(string $event_id, string $text = 'Register now') {
// URLs must be absolute as this shortcode may be used by the au.com.agileware.evaluatewpshortcode extension
$url = CRM_Utils_System::url('civicrm/event/register', ['id' => $event_id],TRUE,NULL,TRUE,TRUE);
return '<a target=_blank href="' . $url . '">Register now</a>';
return '<a target=_blank href="' . $url . '">' . $text . '</a>';
}

private function get_event_info_link_html(string $event_id, string $text = 'More information') {
Expand Down

0 comments on commit 44f2004

Please sign in to comment.