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" buttonhomepage-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
- Install Page Manager module
- Create two Page Manager variants for the homepage with different selection conditions (e.g., one for anonymous, one for authenticated)
- Configure a tour with
route_name: page_manager.page_view_homepage_homepage-layout_builder-0(the anonymous variant) - Visit the front page as anonymous user
- Expected: Tour is found and displayed
- 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
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
saidatomComment #4
saidatomComment #5
smustgrave commentedThis should include test coverage
Comment #6
anybodyComment #7
saidatomComment #9
smustgrave commented