I'm creating a menu that links to taxonomy terms. Those links are saved pointing to the default taxonomy term route name.

The way page manager works now, the route name that is actually used on a given request might however be a completely different one.

The result is that MenuActiveTrail::getActiveLinks() doesn't find any links for the actual route name and the active trail doesn't work.

I have no idea how to fix this.

Comments

Berdir created an issue. See original summary.

dawehner’s picture

urgs

tim.plunkett’s picture

Ouch.
So the route object does contain the correct/expected route name. See this code from RouteNameResponseSubscriber:
$route_name = $this->routeMatch->getParameter('base_route_name') ?: $this->routeMatch->getRouteName();

Perhaps we could trick everything into thinking it's actually that route name?

m.abdulqader’s picture

Priority: Normal » Critical
Status: Active » Needs work

The issue of base route name almost break every thing related to node route.

Here is the list of things I did work a round solution to solve:

  • Active trail.
  • System menu block.
  • Breadcrumbs
  • Tabs

This issue should be considered as Critical.

Regards

m.abdulqader’s picture

Hello All,

I have a question, Is creating a page manager active menu trail that extend the default class, one of the solution or you have another solution in mind.

tim.plunkett’s picture

Priority: Critical » Major

Bugs that have significant repercussions but do not render the whole system unusable are marked major.

tim.plunkett’s picture

Issue tags: +beta blocker triage
george.karaivanov’s picture

Hi.

The problem still exists for all entities. I found why ActiveMenuTrail doesn't work if we override node view and have more than one variant.

If panel page has more than one variant then panels manager add variant_id to route name. Class PageManagerRoutes:

$route = new Route(
          $path,
          [
            '_entity_view' => 'page_manager_page_variant',
            '_title' => $entity->label(),
            'page_manager_page_variant' => $variant_id,
            'page_manager_page' => $page_id,
            'page_manager_page_variant_weight' => $variant->getWeight(),
            // When adding multiple variants, the variant ID is added to the
            // route name. In order to convey the base route name for this set
            // of variants, add it as a parameter.
            'base_route_name' => $route_name,
          ],
          $requirements,
          [
            'parameters' => $parameters,
            '_admin_route' => $entity->usesAdminTheme(),
          ]
        );
        $collection->add($first ? $route_name : $route_name . '_' . $variant_id, $route);
        $first = FALSE;
      }

And when we are on page /node/123 our 'route_name' is 'entity.node.canonical_' . variant_id instead of 'entity.node.canonical'.
That's why MenuActiveTrail will not be set, because in the table 'menu_tree' route_name is 'entity.node.canonical'

jibla’s picture

Hello,
I think my patch solves these issues. I have done changes to VariantRouteFilter.php, which implements RouteFilterInterface. Idea is to once again iterate over routes $collection, and make sure that final route object's name in collection matches its original base_route_name, which btw is preserved in alterRoutes() when creating them. We can see the comments there, which says that base_route_name was added as a parameter exactly for that case when we have multiple routes for multiple variants.

P.S. after you apply patch, you have to clear cache to force routes cache re-generate.

jibla’s picture

bircher’s picture

Status: Needs work » Reviewed & tested by the community
Related issues: +#2649702: Tabs only work for first variant in Node Page

The patch cures the symptoms observed in #2649702

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

This needs test coverage, and also does not follow Drupal's coding standards.

tim.plunkett’s picture

Also, I'm worried this will change the order in some cases.

jibla’s picture

StatusFileSize
new879 bytes

Uploading updated patch. It passes drupal coding standards.

tim.plunkett’s picture

  1. +++ b/src/Routing/VariantRouteFilter.php
    @@ -121,6 +121,18 @@ class VariantRouteFilter implements RouteFilterInterface {
    +    // Fixes the issue related with multiple routes.
    

    Code comments should reflect the code as it is, not in relation to how broken it used to be.

  2. +++ b/src/Routing/VariantRouteFilter.php
    @@ -121,6 +121,18 @@ class VariantRouteFilter implements RouteFilterInterface {
    +    // Idea is to once again iterate over routes $collection,
    ...
    +    // matches its original base_route_name, which btw is preserved
    

    "Idea is" is not a valid beginning to an English sentence. And "btw" isn't a word.

    Also this paragraph isn't wrapped properly to 80 characters.

Still needs tests and needs to preserve the order of the collection.

jibla’s picture

StatusFileSize
new2.67 KB

Updated patch file.

  • Changed comments text
  • Preserving the order of the collection
  • Added unit tests
jibla’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 16: multiple_routes_break-2634276-16.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new2.2 KB
new2.65 KB

This still needs integration tests for something like active trail or whatever else was broken, not just a unit test.

Fixed the unit test, simplified the logic of the loop, and rewrote the docs.

fran seva’s picture

Hi @all -- I started to work in the test but when I tried to reproduce the error (manually) overriding node/{node} page and adding 2 variants I couldn't reproduce the error.
Could someone clarify the steps to reproduce the error?

Thanks!

hkirsman’s picture

Last patch fixes the tab issue: https://www.drupal.org/node/2649702

hkirsman’s picture

fran seva, I understand that only the first variant works. Did you check both? Mine had 3 variants and the second one didn't work (but I didn't test the others).

kiwad’s picture

I use the patch from #19 to show a menu block in a left column. It works.

But if I add a block "Page title (core)" in my Panel variant, the output of the block is empty(edit : not related...)

japerry’s picture

Slightly related -- taxonomy term view pages with core conflicts with page manager overrides if you use the same route.

youfei.sun’s picture

Fixed my issue of showing admin tabs only on first varient.

AndersNielsen’s picture

Tested #19, fixed the issue for me. Thumbsup :)

tim.plunkett’s picture

Had to absorb this into #2736385: Page Manager routing is overly complex and brittle: breaks REST, active trail, fallback pages. Not closing this yet, but please try that patch out.

tim.plunkett’s picture

Status: Fixed » Closed (fixed)

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