Score:0

How to configure Page Manager variants based on Domain module?

cn flag

I've inherited a Drupal 8 website that must be upgraded to Drupal 9. The site has several subdomains declared, using Domain module.

Some pages are build with Page Manager, having 2 variants based on a domain selection criteria basis:

  • Variant "A" should be selected when the domain is www.example.com. I.e.: www.example.com/example-page
  • Variant "B" should be selected when the domain is NOT www.example.com. I.e.: subdomain1.example.com/example-page

I can confirm that this behavior worked in Drupal 8.9, prior to upgrade to Drupal 9. However, now I can't set a selection criteria based on a domain in the UI. I've forced it overriding the config yaml by adding a domain rule on the selection_criteria key, but I don't know if I did it properly. This is an example:

page_manager.page_variant.example-block_display-1.yml

uuid: ad75cd71-ab2f-42af-92d1-599824223224
langcode: 
status: true
dependencies:
  config:
    - page_manager.page.example
    - views.view.example
  module:
    - system
    - views
    - domain
id: example-block_display-1
label: 'Variant 1'
weight: 0
variant: block_display
variant_settings:
  id: block_display
  label: null
  weight: 0
  uuid: d23c2a50-17c7-4777-a419-c7c2200fc9f9
  blocks:
    dd22957b-c81d-43f3-bb28-c209f17db480:
      id: 'views_block:example-example'
      label: ''
      label_display: '0'
      provider: views
      context_mapping: {  }
      views_label: ''
      items_per_page: none
      exposed: {  }
      region: top
      weight: 0
      uuid: dd22957b-c81d-43f3-bb28-c209f22db480
  page_title: 'Variant 1 page title'
page: example
selection_criteria:
  1:
    id: domain
    negate: true
    context_mapping: {  }
    www_example: www_example
selection_logic: and
static_context: {  }

page_manager.page_variant.example-block_display-2.yml

uuid: ad75cd71-ab2f-42af-92d1-599124223224
langcode: 
status: true
dependencies:
  config:
    - page_manager.page.example
    - views.view.example
  module:
    - system
    - views
    - domain
id: example-block_display-2
label: 'Variant 2'
weight: 0
variant: block_display
variant_settings:
  id: block_display
  label: null
  weight: 0
  uuid: d23c2a50-17c7-4777-a419-c7c1100fc9f9
  blocks:
    dd22957b-c81d-43f3-bb28-c209f17db480:
      id: 'views_block:example-example'
      label: ''
      label_display: '0'
      provider: views
      context_mapping: {  }
      views_label: ''
      items_per_page: none
      exposed: {  }
      region: top
      weight: 0
      uuid: dd22957b-c81d-43f3-bb28-c209112db480
  page_title: 'Variant 2 page title'
page: example
selection_criteria:
  1:
    id: domain
    negate: false
    context_mapping: {  }
    www_example: www_example
selection_logic: and
static_context: {  }

Any idea to get it working?

I've installed these modules:

  • drupal/domain: "^1.0@beta"
  • drupal/domain_config: "^1@alpha"
  • drupal/domain_site_settings: "^1.4"
  • drupal/page_manager: "^4.0@RC"

I'm currently using Drupal 9.5.9, PHP 8.1.16 and MariaDB 10.5.19

Any help would very appreciated.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.