In D7 Page Manager (actually, the "Panels" variant) it was possible to disable the Drupal blocks/regions used on a page when viewing a particular Page Manager page. This was useful if there were some blocks configured to show up in the sidebar on all pages, but you wanted to hide them so your Page Manager page could take up the full width of the page.

Yes, we'll need to implement this in Panels' DisplayVariant as well! But since Page Manager is providing a variant to show blocks, this does kinda make sense here too. Although, I'd be open to arguments about why we should do this only in Panels instead. :-) Please let me know what you think!

Implementation ideas

  1. The checkbox will need to be added to the edit form. In D7, the title was "Disable Drupal blocks/regions" and the description was "Check this to have the page disable all regions displayed in the theme. Note that some themes support this setting better than others. If in doubt, try with stock themes to see.". This probably belongs in: src/Plugin/DisplayVariant/BlockDisplayVariant.php and it's buildConfigurationForm()
  2. Page Manager needs to be able to find pages where there is a variant selected that has this set... I'm really not sure how to do this. In D7, it uses the "task" system, that I don't entirely understand. @tim.plunkett: Do you have any ideas?
  3. \Drupal\page_manager\EventSubscriber\BlockPageDisplayVariantSubscriber::onSelectPageDisplayVariant (in the current patch on this issue) needs to check if the current variant from Page Manager has this option enabled.

Comments

dsnopek’s picture

Issue summary: View changes

I made an attempt at some ideas for how to implement in the issue summary...

dsnopek’s picture

Issue summary: View changes
dsnopek’s picture

Issue summary: View changes
tim.plunkett’s picture

StatusFileSize
new1.84 KB

Needs a UI toggle, and \Drupal\page_manager\EventSubscriber\BlockPageDisplayVariantSubscriber::onSelectPageDisplayVariant needs to check it.

But this works just for now.

dsnopek’s picture

Issue summary: View changes
Status: Active » Needs work

Thanks, Tim! I didn't know about the "simple_page" variant. I've updated the issue summary.

Two things:

  1. Do we need to set the priority on the EventSubscriber to make sure it happens after the one registered by the Block module?
  2. What do you think about #2 in the "Implementation ideas" in the issue summary? We want any variant to be able to opt out of blocks - should add an accessor method to one of the interfaces? Or add a new interface for Variants who want to have this option? Or...?

Thanks again!

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new890 bytes
new1.84 KB

By the way, if these pass, we need tests to prove they shouldn't.

#5.1 Yes, we should.
#5.2 Not sure yet, still thinking on it.

tim.plunkett’s picture

Issue tags: +Needs tests
StatusFileSize
new4.55 KB

Right now the only thing in core that uses ThirdPartySettings are config entities, so I tacked this onto Page via that.

However, instead of a nice snippet like
$variant->setThirdPartySetting('page_manager', 'no_blocks', TRUE);
we're stuck with

$settings = $page->getThirdPartySettings('page_manager', $display_variant_id);
$settings['no_blocks'] = $form_state->getValue('no_blocks');
$page->setThirdPartySetting('page_manager', $display_variant_id, $settings);

in order to key it by the variant.

It also made for some exceedingly confusing config schema wrangling, but I figured it out...

This still needs a ton of tests. That can wait until tomorrow.

Status: Needs review » Needs work

The last submitted patch, 7: 2458563-empty-blocks-7.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new12.07 KB
new5.02 KB

Status: Needs review » Needs work

The last submitted patch, 9: 2458563-empty-blocks-9.patch, failed testing.

tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett
Status: Needs work » Needs review
StatusFileSize
new6.22 KB
new9.14 KB
new6.73 KB

That interdiff was wrong, sorry. Here's one from #7.
And that last bug is silly, getThirdPartySettings vs getThirdPartySetting

wim leers’s picture

wim leers’s picture

Status: Needs review » Needs work
  1. +++ b/src/EventSubscriber/DisableBlocksDisplayVariantSubscriber.php
    @@ -0,0 +1,51 @@
    +class DisableBlocksDisplayVariantSubscriber implements EventSubscriberInterface {
    ...
    +        if (!empty($settings['no_blocks'])) {
    

    All of the wording is block-specific. But really, if there's also a PonycornPageVariant, this would override that too.

    Note that if you really want this to override anything else, then you'll also want to call $event->stopPropagation().

  2. +++ b/src/EventSubscriber/DisableBlocksDisplayVariantSubscriber.php
    @@ -0,0 +1,51 @@
    +   * Selects the block page display variant.
    

    Exactly the opposite, actually :)

  3. +++ b/tests/src/Unit/DisableBlocksDisplayVariantSubscriberTest.php
    @@ -0,0 +1,115 @@
    + * Contains
    + *   \Drupal\Tests\page_manager\Unit\DisableBlocksDisplayVariantSubscriberTest.
    

    Oopsie :)

RKopacz’s picture

Whatever happened to this feature. Has it been added? I am playing with 8.x-1.0-alpha24 , and do not see it anywhere, and would like to have this feature available. Has it been dropped?

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned

If the feature was present then it wouldn't need a feature request. It still needs work.

gambry’s picture

Status: Needs work » Needs review
StatusFileSize
new4.26 KB

A lot have changed in page_manager since #11, so I tried to keep its ideas while using the new classes interfaces and models.

I've excluded the tests as I first want to be sure my approach is correct. Specifically:

  1. I'm not sure if having the opt-in option in the variant was the plan, although this is what the summary suggests.
  2. I'm not sure if the way I use to get PageVariant settings is best practice.

Status: Needs review » Needs work

The last submitted patch, 16: allow_disabling_drupal-2458563-16.patch, failed testing.

gambry’s picture

StatusFileSize
new4.79 KB
new1.37 KB

Been lazy and thought I could get away without updating the schema.

This comes green locally.

gambry’s picture

Status: Needs work » Needs review
damienmckenna’s picture

Minor complaint, but I don't like the setting name "force_simplepage".

Something to consider - might there be other display plugins which could be listed? In other words, might it be better to make this a selector to e.g. choose between "Normal page (default)" and "Hide other blocks on the page", so that maybe there could be extended beyond these two, or would that be over-engineering it?

gambry’s picture

Issue tags: +DevDaysSeville

@DamienMcKenna I agree is terrible name, but due #13.1 I couldn't find anything better.
My original idea was to use the 'This variant owns the page, so no other/external blocks, regions, content will be displayed" naming convention, which covers #13.1 and still mention the old reference to blocks and regions. But I couldn't find a shorter key-name version. :p

I'll try to get hold of @Wim Leers at DDD.

gambry’s picture

Status: Needs review » Needs work

@Wim Leers mentioned at least another module is using RenderEvents::SELECT_PAGE_DISPLAY_VARIANT event: RefreshLess.

The idea of the dropdown is a good one. I'll work on it, together with:

  1. +++ b/src/EventSubscriber/ForceSimplePageVariantSubscriber.php
    @@ -0,0 +1,61 @@
    +      $routes = \Drupal::service('router.route_provider')->getRoutesByPattern($page->getPath())->all();
    

    Use dependency injection.

  2. +++ b/src/EventSubscriber/ForceSimplePageVariantSubscriber.php
    @@ -0,0 +1,61 @@
    +      -10
    

    This should have a comma at the end.

japerry’s picture

Status: Needs work » Closed (outdated)

Page Manager 8.x-1.x is no longer supported, closing.

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.