Problem/Motivation

Issue #3165435 fixed tour matching when <front> is configured but a node is set as the homepage. However, the fix introduced a limitation: tours configured with specific page manager variant routes
are no longer found on the front page.

When using Page Manager to create different page variants for the front page (e.g., one for anonymous users and one for authenticated users), each variant has a distinct route name like
page_manager.page_view_homepage_homepage-layout_builder-0. Tours configured with these specific variant routes are never found because loadTourEntities() converts the route to <front> before
querying and only queries for <front>.

Use case: We have two homepage page variants:

  • homepage-layout_builder-0 (for anonymous users) - includes a "Guided tour" button
  • homepage-layout_builder-1 (for authenticated users) - no tour button

The tour should only appear for anonymous users, so it's configured with:

  routes:
    -
      route_name: page_manager.page_view_homepage_homepage-layout_builder-0
  

With the current code, this tour is never found because the query only looks for <front>.

Steps to reproduce

  1. Install Page Manager module
  2. Create two Page Manager variants for the homepage with different selection conditions (e.g., one for anonymous, one for authenticated)
  3. Configure a tour with route_name: page_manager.page_view_homepage_homepage-layout_builder-0 (the anonymous variant)
  4. Visit the front page as anonymous user
  5. Expected: Tour is found and displayed
  6. Actual: Tour is not found because query only matches <front>

Proposed resolution

On the front page, query for both <front> AND the actual route name to support page manager variants:

  $actual_route_name = $this->currentRouteMatch->getRouteName();
  $is_front_page = $this->pathMatcher->isFrontPage();
  $route_name = $is_front_page ? '' : $actual_route_name;

  // On the front page, also query for the actual route name to support
  // page manager variants (e.g., different layouts for anonymous vs
  // authenticated users with different route names).
  $route_names_to_query = [$route_name];
  if ($is_front_page && $actual_route_name !== ') {
    $route_names_to_query[] = $actual_route_name;
  }

  // Use IN condition when querying multiple route names
  if (count($route_names_to_query) > 1) {
    $query->condition('routes.*.route_name', $route_names_to_query, 'IN');
  }
  

This allows tours to be configured with either <front> (matches any front page) or a specific page manager variant route (matches only that variant).

Remaining tasks

  • Review patch
  • Add/update tests
  • Commit

User interface changes

None.

API changes

None. This is a bugfix that extends the existing behavior to support additional route configurations.

Data model changes

None.

Title: loadTourEntities() should also query for actual route name on front page to support page manager variants

Related issues: #3165435

Issue fork tour-3568815

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

saidatom created an issue. See original summary.

saidatom’s picture

Issue summary: View changes

saidatom’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work

This should include test coverage

anybody’s picture

Issue tags: +Needs tests
saidatom’s picture

Status: Needs work » Needs review

shivansh_0909 made their first commit to this issue’s fork.

smustgrave’s picture

Status: Needs review » 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.