1

I am trying with no luck to update a layout to a specific page only to our Magento 2.4.3 store.

CMS Page URL key is:

product-finder

I have created in child theme folder this xml file:

app/design/frontend/MyVendor/child_theme/Magento_Cms/layout/cms_page_view_selectable_ product-finder_ProductFinderlayout.xml

just like Magento docs suggest. Inside Magento_Cms folder as I want a CMS Page to update only.

Cleared caches but in admin in product-finder CMS Page, there is no Custom Layout Update option in the dropdown.

What did I do wrong, please?

1
  • any luck? I reproduced this locally to get it working to produce answer I provided. The quote from devdocs at end of my answer was a little confusing and maybe has something to do with the issue. Also I guess if you have a custom theme selected for that cms block that might affect which theme Magento reads your custom layout updates from.
    – sdaugherty
    Jan 3, 2022 at 2:56

2 Answers 2

3

File tree:

app/design/frontend/MyVendor
└── child_theme
    ├── Magento_Cms
    │   └── layout
    │       └── cms_page_view_selectable_product-finder_ProductFinderLayout.xml
    ├── composer.json
    ├── registration.php
    └── theme.xml

registration.php

<?php

use Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(
    ComponentRegistrar::THEME,
    'frontend/MyVendor/child_theme',
    __DIR__
);

theme.xml

<parent /> = parent theme yours is inheriting from

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>MyVendor - Child Theme</title>
    <parent>Magento/blank</parent>
</theme>

cms_page_view_selectable_product-finder_ProductFinderLayout.xml

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block name="test" class="Magento\Framework\View\Element\Text">
                <arguments>
                    <argument translate="true" name="text" xsi:type="string">Some Custom Text</argument>
                </arguments>
            </block>
        </referenceContainer>
    </body>
</page>

Configuration:

  1. In the admin, make sure the theme you mentioned is the one set for this website
    • Under Content > Design > Configuration
  2. Clear cache after configuration changes
  3. Edit "Product Finder" CMS Page

Design Configuration

Design Configuration Grid

CMS Page Custom Layout Options

CMS Page - Custom Layout Update Option

https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/xml-manage.html#create-cms-pageproductcategory-specific-selectable-layouts

Selectable layout updates can only be loaded from the global store theme and work only in the single website with single theme configurations. If a specific entity like cms-page/product/category has an individual theme applied in the design configuration tab, the selected theme will have priority over the selected layout update.

2
  • No need for so much work. It should work with only name in xml
    – G. G.
    Jan 10, 2022 at 12:15
  • I only added more detail of what should already be in place for the theme in case others are looking at this having the same problem. The theme definition and it being applied to a website are necessary steps before Magento will show the custom layout update options from your theme...under normal conditions. Is it still not working?
    – sdaugherty
    Jan 10, 2022 at 18:59
1

I had the same issue today as well. My file structure is as follows:

app/design/frontend/MyVendor 
└── main_theme
    ├── Magento_Cms
    │   └── layout
    │       └── cms_page_view_selectable_product-finder_ProductFinderLayout.xml 
└── child_theme
    ├── Magento_Cms
    │   └── layout
    │       └── cms_page_view_selectable_product-finder_ProductFinderLayout.xml
    ├── composer.json
    ├── registration.php
    └── theme.xml

Turns out I had to copy the cms_page_view_selectable_product-finder_ProductFinderLayout.xml file in both the main_theme as the child_theme for this to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.