Page Manager's current method of providing variants for existing system paths involves overriding their Routes with Entity View routes. This is not ideal for at least two reasons:

  1. Information associated with original routes is lost
  2. The entire region setup as configured in the Panels variant content settings is rendered inside a 'Main Content' block.

I've made some changes that bypass Page Manager's route override entirely by the following process:

  1. A new RouteSubscriber class for Panels Everywhere removes any route overrides added by Page Manager's subscriber, and instead adds the page ID as a parameter in the original route's _defaults.
  2. Panels Everywhere's DisplayVariantSubscriber now checks the RouteMatch for the new Page ID parameter and, if found, loads the corresponding Page entitty instead of the generic /site_template one. The generic entity is still loaded for any routes that do not have a Page ID associated with them.
  3. A checkbox for disabling route overrides is added to Page Manager's forms.


NOTE: currently, this requires page_manager to be patched with the following:
http://cgit.drupalcode.org/page_manager/commit/?id=292cddfeca17bea8b95fb...
EDIT: the patch has since been committed to the main branch.

This is the first patch I've ever submitted, the first issue I've ever opened, and the first time I've interacted on Drupal.org in any capacity - so I apologize in advance if any and all of the above fails to conform to the community's standards. Please let me know of anything I could have done better if you can - I would appreciate it very much!

CommentFileSizeAuthor
#24 panels_everywhere--display_variant_without_route_overrides--22-24.interdiff.txt25.12 KBAlumei
#24 panels_everywhere--display_variant_without_route_overrides--2858004-24.patch37.86 KBAlumei
#22 panels_everywhere--display_variant_without_route_overrides--20-22.interdiff.txt1.56 KBAlumei
#22 panels_everywhere--display_variant_without_route_overrides--2858004-22.patch13.95 KBAlumei
#20 display_variant_without_route_overrides-2858004-20.patch13.82 KBnonAlgebraic
#19 display_variant_without_route_overrides-2858004-19.patch0 bytesnonAlgebraic
#16 panels_everywhere-display_variant_without_route_overrides-2858004-16.patch15.34 KBAlumei
#9 2858004-9.patch16.39 KBnonAlgebraic
#9 interdiff-2858004-8-9.txt745 bytesnonAlgebraic
#8 interdiff-2858004-5-8.txt4.25 KBnonAlgebraic
#8 2858004-8.patch16.08 KBnonAlgebraic
#5 interdiff-2858004-4-5.txt5.08 KBnonAlgebraic
#5 2858004-5.patch15.88 KBnonAlgebraic
#4 interdiff-2858004-3-4.txt687 bytesnonAlgebraic
#4 2858004-4.patch15.78 KBnonAlgebraic
#3 interdiff-2858004-2-3.txt7.01 KBnonAlgebraic
#3 2858004-3.patch15.72 KBnonAlgebraic
#2 panels_everywhere-no-route-overrides-8.x-2.patch12.2 KBnonAlgebraic
panels_everywhere-no-route-overrides-8.x.patch10.72 KBnonAlgebraic
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nonAlgebraic created an issue. See original summary.

nonAlgebraic’s picture

Re-roll with functioning access controls.

Background: currently, PanelsEverywherePageDisplayVariantSubscriber performs an access check on the page variant by calling the parent PageVariant's resolveConditions function directly. This will always fail (for any variants with selection conditions) because the conditions returned by getSelectionConditions never undergo context mapping and thus when the execution gets to a ContextAwarePlugin there will not be a 'context' field in the configuration.

Instead, the subscriber should make use of PageVariant's own access handler, which performs context mapping.

nonAlgebraic’s picture

Some style improvements and a new overridable method in the variant subscriber class.

nonAlgebraic’s picture

Added $event.stopPropagation() in the variant subscriber to ensure that if a matching page is found, no further page variant changes will occur (it is Panels everywhere after all, isn't it?)

nonAlgebraic’s picture

Better decision logic between overriding routes and standalone ones.

DamienMcKenna’s picture

Status: Needs work » Needs review
nonAlgebraic’s picture

Issue summary: View changes
nonAlgebraic’s picture

Cleaned up the variant resolution process.

nonAlgebraic’s picture

Added a small helper function to get the main content from the variant, if available.

Alumei’s picture

Is this still relevant for the current 8.x-4.x branches of PE and this module?

nonAlgebraic’s picture

@Alumei I'm running panels:4.2 and page_manager 4.0.0-beta2 (with core:8.4.0) and it's still relevant, as Page Manager still uses the "route override" strategy for existing routes, and is still subject to Panels' default approach of rendering the page variant as the "Main Content" block *within* the original page.

Alumei’s picture

@nonAlgrebraic I tried running the tests on the 8.x-4.x branch, but the patch no longer applies, can you do a reroll of the patch against that branch?

Also, if I'm reading the commit-log of pange-manager right, the patch mentioned in the issue summary is already included in the 8.x-4.0-beta2 version. Should we maybe adjust the required page-manager version accordingly?

nonAlgebraic’s picture

Issue summary: View changes
nonAlgebraic’s picture

@Alumei sorry, I misread your previous comment. I understand now that the 8.x-4.x branch you're referring to is for Page Manager, not Panels Everywhere. The patches I've attached here are for Panels Everywhere.

You're also right about Page Manager merged the other patched I mentioned in the issue summary, so I edited the OP to reflect that it's no longer necessary. Thanks!

Alumei’s picture

@nonAlgrebaic Oh, I see. Some additional info might have been helpful.
Actually I meant the 8.x-4.x of Panels Everywhere. From the issue queue I gathered that development for the 1.x was dropped in favor of creating 4.x release, matching panels and page managers versions.
Therefore I asked about the applicability for the 8.x-4.x branch in my comment #10. After your remark I triggered the Testbot to apply your latest patch to the 4.x branch and run the recently added tests.
There the Testbot informed that the patch does not apply, see the results for you patch in #9.
As such I wanted to ask you in #12 to reroll the patch so that it applies to the 8.x-4.x branch.

I hope this helps, sorry for the misunderstanding.

Alumei’s picture

Attempted reroll of the patch in #9 against 8.x-4.x branch

Status: Needs review » Needs work

The last submitted patch, 16: panels_everywhere-display_variant_without_route_overrides-2858004-16.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

nonAlgebraic’s picture

Version: 8.x-1.x-dev » 8.x-4.x-dev
nonAlgebraic’s picture

@alumei gotcha, sorry for the miscommunication!

Here's a re-roll that should work.

nonAlgebraic’s picture

Oops, bad upload. Here we go.

Alumei’s picture

Note: I just created #2933423: Content of placed title block does not show up and remembered seeing a fix for that in this issue #9. I'll try applying it over there.

Alumei’s picture

Status: Needs work » Needs review
FileSize
13.95 KB
1.56 KB

Fixed the test failures.

This will need additional tests as the patch adds at least these new features:

  • Allow for additional page manager definitions instead of only site template.
  • Remove page manager overrides if a certain option is set.
DamienMcKenna’s picture

Status: Needs review » Needs work

Needs work per #22.

Alumei’s picture

I added a unit test for PanelsEverywhereRouteSubscriber and fixed some edge cases in the process.

Needs review only to trigger testbot.

DamienMcKenna’s picture

Title: Use PE's Superiour Display Variant on Any Path Without Route Overrides » Use PE display variant on any path without route overrides

DamienMcKenna’s picture

Status: Needs review » Fixed
Parent issue: » #2845415: Plan for Panels Everywhere 8.x-4.0 release

Committed. Thanks.

Status: Fixed » Closed (fixed)

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