Skip to content

Page layouts are hard-coded in Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Chooser\Container #30471

Closed
@ericmorand

Description

@ericmorand

Preconditions (*)

Magento 2.3.5

Steps to reproduce (*)

Have a look at the code source of Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Chooser\Container.

Expected result (*)

The function getPageLayouts() should return the actual list of page layouts declared by the different modules.

Actual result (*)

The function getPageLayouts() only returns the one provided by Magento_Theme, and they are hard-coded in the file:

    /**#@+
     * Frontend page layouts
     */
    const PAGE_LAYOUT_1COLUMN = '1column-center';
    const PAGE_LAYOUT_2COLUMNS_LEFT = '2columns-left';
    const PAGE_LAYOUT_2COLUMNS_RIGHT = '2columns-right';
    const PAGE_LAYOUT_3COLUMNS = '3columns';
    /**#@-*/

   [...]

  /**
     * Retrieve page layouts
     *
     * @return array
     */
    protected function getPageLayouts()
    {
        return [
            self::PAGE_LAYOUT_1COLUMN,
            self::PAGE_LAYOUT_2COLUMNS_LEFT,
            self::PAGE_LAYOUT_2COLUMNS_RIGHT,
            self::PAGE_LAYOUT_3COLUMNS,
        ];
    }

Workaround

I may be possible to override Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Chooser\Container and to inject an instance of Magento\Framework\View\Model\PageLayout\Config\BuilderInterface to grab the list of available page layouts from there. Untested though.

Thoughts

Basically, it makes any container with Label declared in a non-Magento Theme page layout not selectable from the back-office to inject widgets. But the simple fact that Magento_Widget assumes that some page layouts exist is concerning. This concern is actually confirmed by the fact that one of the four hard-coded page layouts doesn't even exist: 1column-center.


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Issue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: ready for confirmationPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReported on 2.3.5Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions