Use String.match to correlate regions when switching Layouts in Panels IPE

Created on 16 May 2017, over 7 years ago
Updated 25 June 2024, 6 months ago

Problem/Motivation

We have a lot of layouts on our site, and very few of them have identical region names. As a result, when using Panels IPE to switch layouts, most blocks end up in the first region of the new layout as no region names are identical.

Here are two example layouts provided by the Zurb Foundation theme:

foundation_2col:
  label: 'Foundation: 2 column row'
  path: layouts/foundation_2col
  template: foundation-2col
  category: 'Foundation: 2'
  regions:
    left:
      label: Left
    right:
      label: Right
  icon: foundation_2col.png

foundation_2col_bricks:
  label: 'Foundation: 2 column bricks'
  path: layouts/foundation_2col_bricks
  template: foundation-2col-bricks
  category: 'Foundation: 2'
  regions:
    top:
      label: Top
    above_left:
      label: Above Left
    above_right:
      label: Above Right
    middle:
      label: Middle
    below_left:
      label: Below Left
    below_right:
      label: Below Right
    bottom:
      label: Bottom
  icon: foundation_2col_bricks.png

As an end user, I would expect "left" from foundation_2col to map to "above_left" or "below_left" from foundation_2col_bricks, but the current logic requires region names to be equal.

Proposed resolution

Use String.match() to correlate regions, so that if the old region name contains the new region name, or vice versa, that new region is used. Some examples of mappings:

middle => middle (exact matches will take priority over fuzzy matches)
left => above_left
below_right => right
top => featured_top

Remaining tasks

Review patch, talk about usefulness. This is a nice-to-have for sure and is low priority IMO.

User interface changes

None.

API changes

None.

Data model changes

None.

✨ Feature request
Status

Needs work

Version

4.0

Component

In-Place Editor (IPE)

Created by

πŸ‡ΊπŸ‡ΈUnited States samuel.mortenson

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024