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)
Command icon 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

ryankavalsky created an issue. See original summary.

owenbush’s picture

StatusFileSize
new116.09 KB

This 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.

Screenshot of series title

owenbush’s picture

Status: Active » Postponed (maintainer needs more info)

Marking as postponed as I need some more info to be able to recreate this.

ryankavalsky’s picture

StatusFileSize
new38.46 KB
new29.91 KB

Thanks 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>

ryankavalsky’s picture

StatusFileSize
new53.42 KB
new69.46 KB
ryankavalsky’s picture

I 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.

ryankavalsky’s picture

StatusFileSize
new1.85 KB

This 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.

ryankavalsky’s picture

StatusFileSize
new1.75 KB

I'm not sure why, but one of my environments was showing an error when calling:

$eventseries->get('title')->getValue()

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:

$eventseries->label()
jrb’s picture

StatusFileSize
new1.61 KB

We 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.

jrb’s picture

One 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.

ju.vanderw’s picture

StatusFileSize
new86.31 KB
new374.54 KB
new517.29 KB

i 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.

muriqui’s picture

Version: 2.0.0-beta2 » 3.0.x-dev

muriqui’s picture

Status: Postponed (maintainer needs more info) » Needs work

Rerolled 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,

This 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.

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.

muriqui’s picture

Status: Needs work » Needs review
eric.napier’s picture

Status: Needs review » Reviewed & tested by the community

Tested in an integration environment with Recurring Events enabled. Fix works as expected and code reviewed for standards / best practice.

  • muriqui committed ffa5bb99 on 3.0.x
    fix: #3193041 Show Series Title as the Page's Title in the Browser Tab...
muriqui’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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