Problem/Motivation
Does any know how to set the page's title (what shows up in the browser's tab) on a Series page (/events/series/#)? I've tried the following, but nothing has worked so far:
- Adding a hard-coded _title under entity.eventseries.canonical > defaults in modules\contrib\recurring_events\recurring_events.routing.yml
- Adding a dynamic _title_callback, also under entity.eventseries.canonical > defaults in modules\contrib\recurring_events\recurring_events.routing.yml. I tried setting this value to:
- '\Drupal\recurring_events\Controller\EventSeriesController::addPageTitle' (just to get something to show up)
- '\Drupal\recurring_events\Controller\EventInstanceController::getTitle' (after adding public function getTitle(EventInterface $eventseries) {...} to modules\contrib\recurring_events\src\Controller\EventSeriesController.php)
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | Screenshot 2025-05-02 at 11.48.17 AM.png | 517.29 KB | ju.vanderw |
| #11 | Screenshot 2025-05-02 at 11.47.59 AM.png | 374.54 KB | ju.vanderw |
| #11 | Screenshot 2025-05-02 at 11.45.09 AM.png | 86.31 KB | ju.vanderw |
| #7 | recurring_events-3193041-7.patch | 1.85 KB | ryankavalsky |
| #5 | title not in tab.jpg | 69.46 KB | ryankavalsky |
Issue fork recurring_events-3193041
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
owenbush commentedThis seems to be working for me already, providing you have the title field being displayed in the Manage Display of the particular event series type you're viewing. Attached is a screenshot of it working for me.
Comment #3
owenbush commentedMarking as postponed as I need some more info to be able to recreate this.
Comment #4
ryankavalsky commentedThanks for checking that out. I'm not sure what the issue is, but my title field is definitely included in the display, but it's still not in the tab. If it helps, our theme has some html overrides, though setting the theme back to Bartik doesn't fix this anyway.
html.html.twig:
<title>{{head_title.title}}</title>Comment #5
ryankavalsky commentedComment #6
ryankavalsky commentedI should have checked this earlier, but I've checked the log and saw that the issue falls on Easy Breadcrumb: "Easy Breadcrumb could not determine the title to use for /events/series/{eventseries}". I'll look into that.
Comment #7
ryankavalsky commentedThis patch should fix the issue. The problem was that the '/events/series/{eventseries}' router didn't have a title callback set, so other modules like Easy Breadcrumb didn't know how to set it.
The patch adds the title callback to recurring_events.routing.yml, and adds a new langcode variable and getTitle() function to src\Controller\EventSeriesController.php. It should apply cleanly to at least 2.0.0-beta2.
Comment #8
ryankavalsky commentedI'm not sure why, but one of my environments was showing an error when calling:
The error was "Placeholders must have a trailing [] if they are to be expanded with an array of values". So, I've re-rolled the patch to use the following instead:
Comment #9
jrbWe were having the same issue, and the patch in #8 fixed the problem.
Attached is a re-roll that just fixes an incorrect parameter comment for the new
EventSeriesController::getTitle()method.Comment #10
jrbOne note...
Similar to what @ryankavalsky said about Easy Breadcrumb, you also might not see this issue if you don't have the Metatag module enabled.
@owenbush, that may be why you didn't see it in #2 above.
Comment #11
ju.vanderw commentedi am having this same issue.
The event series title does not appear on Easy Breadcrumb breadcrumb block, and on the browser tab. In the metatag, it is definitely missing.
Patch #9 worked for me - however, in the breadcrumb, it doesn't register that the title that is showing is the last item, which means the previous item does not render as a link.
Comment #12
muriqui commentedComment #14
muriqui commentedRerolled the patch for 3.x and submitted as an MR.
The issue here is that the entity.eventseries.canonical route doesn't have a title callback defined, which is what is normally used by the browser title and the system's "Page title" block.
As owenbush noted above,
But that's not typically needed; you shouldn't have to place the Title field in Manage Display to get a page title on an entity's canonical route. See nodes, for example: the Manage Display page doesn't even list the Title field.
Likewise, if you go to Manage Display for an eventinstance, you can disable the Title field, and the page title still works on the instance pages because entity.eventinstance.canonical does have a title callback.
Comment #15
muriqui commentedComment #16
eric.napier commentedTested in an integration environment with Recurring Events enabled. Fix works as expected and code reviewed for standards / best practice.
Comment #18
muriqui commented