Customizable views area handlers ids

Created on 27 May 2025, 2 months ago

Problem/Motivation

Currently, when adding an area plugin to a view's display (like say for example a "text_custom" type area), Views automatically generates a machine name, based on the type of area, suffixed by an incremented number, corresponding to the number of areas of the same type already in place.

This works fine, until you decide to customize the output of this display, through a custom template.
Then, when deciding how to print the variable containing those areas, (for example {{ footer }}), you might decide to split those areas (for example, using {{ footer.area_text_custom }} somewhere inside your markup, then {{ footer.area_text_custom_1 }} elsewhere).

If later on you need to delete any or all of those areas, and don't re-create them all, using the exact same order, you will break this template customization.

Proposed resolution

The solution would be to leave it up to the site builder, through the UI, to set a pre-determined area handler id.

โœจ Feature request
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component

views.module

Created by

๐Ÿ‡ซ๐Ÿ‡ทFrance arousseau

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

Merge Requests

Comments & Activities

  • Issue created by @arousseau
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance arousseau
  • Pipeline finished with Failed
    2 months ago
    Total: 143s
    #507506
  • Pipeline finished with Failed
    2 months ago
    Total: 176s
    #507512
  • Pipeline finished with Failed
    2 months ago
    Total: 117s
    #507527
  • Pipeline finished with Success
    2 months ago
    Total: 427s
    #507563
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance arousseau

    I added a rough proof of concept which works ok.

    I had to add the Method Drupal\views\Plugin\views\area\AreaPluginBase::submitOptionsForm() has no return type specified. phpstan error to the list of ignored errors in core/.phpstan-baseline.php since \Drupal\views\Plugin\views\area\Entity already implements it and would break.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance prudloff Lille
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands Lendude Amsterdam

    I would be against doing this in Drupal core, it adds more options to the Views UI which is already too full of options, and this feel very much like an edge case. If you need this in a project you can just add a custom area plugin that does this and use that, right? Just my feeling.

    Back to needs work for the tests.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance prudloff Lille

    My rationale for adding this to core would be that almost every other machine name in Drupal can be customized from the UI.

  • Pipeline finished with Failed
    25 days ago
    Total: 272s
    #541764
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia abhijith s

    abhijith s โ†’ made their first commit to this issueโ€™s fork.

  • Pipeline finished with Success
    19 days ago
    Total: 1012s
    #546989
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance arousseau
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mortona2k Seattle

    Having random machine names in views is quite annoying for developers. I think this should be fixed in core.

    I think it should be included just under the setting for administrative labels. That is in a collapsed element, so to me this increases functionality without adding clutter.

    I want this for fields as well, where you can have duplicate fields that just have _1 _2 at the end, with no way to differentiate semantically.

  • Pipeline finished with Success
    12 days ago
    Total: 490s
    #552893
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance arousseau

    I moved the new input to a details element, under admin label as suggested by @mortona2k

Production build 0.71.5 2024