Comments

the_glitch created an issue. See original summary.

owenbush’s picture

Thanks I'll look into this.

the_glitch’s picture

Any news on this one?

owenbush’s picture

Not at this time.

cluke009’s picture

Posting to help any others that want the title on their registration pages.

You need to get the event instance entity then the event series entity and from there you can actually get the title.

The getTitle() method didn't work for me but you can grab it from the field value.


use Drupal\Core\Url;

/**
 * Implements hook_preprocess_field().
 */
function hook_preprocess_page_title(array &$variables) {

  $route_name = \Drupal::routeMatch()->getRouteName();

  if ($route_name === 'entity.registrant.add_form') {
    // Get event instance from url.
    $url = \Drupal::service('path.current')->getPath();
    $params = Url::fromUri("internal:" . $url)->getRouteParameters();
    $entity_type = key($params);
    $entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($params[$entity_type]);

    // Load event series instance because we cant get title from instance.
    $event = $entity->getEventSeries();
    $variables['title'] = $event->title->value . '<div class="reg-title">Registration</div>';
  }
}
the_glitch’s picture

Thank you cluke009. Unfortunately I'm not a programmer so I have no idea which file to paste this code into. Could you explain how to apply this code please?

Could it be converted to a patch then merged with the next version if it passes testing?

aritrika.d’s picture

StatusFileSize
new1.28 KB
aritrika.d’s picture

Status: Active » Needs review
the_glitch’s picture

Thanks aritrika.d. Your patch #7 applied but caused this fatal error.
PHP Fatal error: Cannot use Drupal\Core\Url as Url because the name is already in use in /var/www/html/modules/contrib/recurring_events/recurring_events.module on line 22

aritrika.d’s picture

StatusFileSize
new1.1 KB
the_glitch’s picture

Thank you. Applied and not causing WSOD but it's printing HTML code in header.

Only local images are allowed.

aritrika.d’s picture

StatusFileSize
new1.05 KB
the_glitch’s picture

Looks like it works but I've got other bugs from other things that are stopping me from testing this properly.

  • owenbush committed dc84d3d on 8.x-1.x
    Issue #3129533 by aritrika.d, the_glitch, owenbush: Display Event Title...

  • owenbush committed 72de4f5 on 2.0.x
    Issue #3129533 by aritrika.d, the_glitch, owenbush: Display Event Title...
owenbush’s picture

Status: Needs review » Fixed

Thank you all for the contributions. I had to move the code over to the recurring_events_registration submodule as it was registration specific. I also streamlined the code a little.

This has been merged into the latest dev branch for both 8.x-1.x and 2.0.x

owenbush’s picture

Issue tags: +rc eligible

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.