Incorrect page_title title in browser toolbar

Created on 20 June 2016, over 8 years ago
Updated 26 August 2024, 3 months ago

On a page manager blocks display page, the variant's configured page title is displaying correctly in the page title block (<h1>), but in the <title> is using the Label set for the Page overall, instead of the defined variant title.

This wouldn't be too bad except I can't find a way to change the Page's label within the UI.

I've tracked the issue down to the _title callback in the dynamic route creation of PageMangerRoutes.php, (currently on) line 99:

'_title' => $entity->label(),

Original report by divined:

$request = \Drupal::request();
$route_object = \Drupal::routeMatch()->getRouteObject();
$page_title = \Drupal::service('title_resolver')->getTitle($request, $route_object);

Return page manager name instead of Page title.

🐛 Bug report
Status

Needs review

Version

4.0

Component

Code

Created by

🇧🇬Bulgaria divined

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇭Switzerland wengerk Lausanne

    Rerolled patch for Drupal 10.3.x

  • Pipeline finished with Failed
    3 months ago
    Total: 287s
    #264543
  • Pipeline finished with Failed
    3 months ago
    Total: 652s
    #264540
  • Pipeline finished with Success
    3 months ago
    Total: 338s
    #264570
  • 🇨🇭Switzerland wengerk Lausanne

    wengerk changed the visibility of the branch 2752227-incorrect-pagetitle-title to hidden.

  • 🇨🇭Switzerland wengerk Lausanne

    Openned an issue fork to run tests againts patch. I found some mistake on the rerolled patch in #50 and fix thoses issues on the Fork.
    Seems to works now. I just rerolled the patch and change this code.

      public function pageTitle($page_manager_page_variant) {
        if (is_string($page_manager_page_variant)) {
            $page_manager_page_variant = $this->entityRepository->loadEntityByConfigTarget('page_variant', $page_manager_page_variant);
        }
    

    to this

      public function pageTitle(Request $request) {
        $attributes = $request->attributes->all();
        if (!isset($attributes['_page_manager_page_variant'])) {
          return '';
        }
    
        if (is_string($attributes['_page_manager_page_variant'])) {
          $page_manager_page_variant = $this->entityRepository->loadEntityByConfigTarget('page_variant', $attributes['_page_manager_page_variant']);
        } elseif ($attributes['_page_manager_page_variant'] instanceof PageVariantInterface) {
          $page_manager_page_variant = $attributes['_page_manager_page_variant'];
        } else {
          return '';
        }
    
Production build 0.71.5 2024