7

I installed a clean version of Magento 2.3.4 with composer and added a template. Then I wanted to edit some pages by inserting some XML code into the "Custom Layout XML" field that is visible in this screen:

Admin with custom xml layout field

But in my admin there is shown another field labeled "Custom Layout Update" not XML:

Admin with custom layout update field

The help tooltip says

List of layout files with an update handle "selectable" matching PageIdentifier_UpdateID. See Magento documentation for more information

But I can't find any information in the documentation and don't know how to enable the "Custom layout xml" field?

1

6 Answers 6

8

The functionality of custom layout updates was removed from Magento to remove the opportunity for Remote Code Execution, so there no way to return it back

see: https://devdocs.magento.com/guides/v2.3/release-notes/release-notes-2-3-4-open-source.html

4
  • As of writing this, the Magento 2.3.4 release notes incorrectly link to the wrong documentation for this change. It should be linked to: devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/…
    – Dustin W
    Feb 7, 2020 at 22:34
  • 2
    When "custom layout update" was removed the column "Custom Layout Update" is still available in the database. In my case it contains all the XML changes I have previously inputted. And Magento is still using the XML changes to render the category pages. Having removed the XML input field and and using XML files moving forward, what should one do with the data in "Custom Layout Update"?
    – user12208
    Mar 18, 2020 at 17:18
  • @KAndy sir, I have face same issue. How to apply different dfifferent list.phtml for each category. Could you please help me?
    – Mehta Prem
    Sep 20, 2020 at 6:50
  • @user12208 Same here. Have you solved that? How?
    – Kiwop
    Oct 21, 2020 at 11:55
7

They go in app/design/frontend/<your_vendor_name>/<your_theme_name>/Magento_Cms/layout/

The file name should be like cms_page_view_selectable_<url-key>_<name>.xml

The name is just any name you want to give the layout. It will be used in the Custom Layout Update selection field in the Design section of the CMS Page edit page. But I noticed that, if the name is multiple words separated by "-" or "_" only the first word shows up in the selection box. So I'm naming them like "landingPage".

5
  • 2
    This is all correct, and just to add on to this answer, if the layout update is for the homepage, Magento currently (2.3.4) has a bug where the layout updates don't apply unless you also create the file cms_index_index_selectable_<url-key>_<name>.xml with the same content as your "cms_page_view" file. For more information see: github.com/magento/magento2/issues/26758
    – Dustin W
    Feb 7, 2020 at 22:35
  • it's working properly. Apr 16, 2020 at 12:07
  • @DustinW Thank you, your comment helped me a lot! Jun 4, 2020 at 14:06
  • Just want to reinforce the key word ALSO in the comment by @DustinW. You need 2 files in your Magento_Cms/layout/ directory: 1) cms_index_index_selectable_<url-key>_<name>.xml; and 2) cms_page_view_selectable_<url-key>_<name>.xml. Wasted over an hour trying to get this to work before I read this comment and discovered the nuance here.
    – Chrysippus
    Jul 2, 2020 at 6:49
  • 1
    If you want to create Layout XML files that can apply to multiple pages, check out this extension github.com/integer-net/magento2-global-custom-layout Sep 15, 2020 at 16:41
2

I followed the same and put the xml in app/code/vendor/module/view/frontend/layout/cms_page_view_selectable_home-page_homelayout.xml

After clearing the cache , i can see the value 'homelayout' in respective cms content edit area dropdown 'custom Layout Update' and updated the same. But cannot see the layout update in frontend?

I used below content in xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="page.top">
        <block class="Magento\Cms\Block\Block" name="home_cusom">
            <arguments>
                <argument name="block_id" xsi:type="string">home_main_block</argument>
            </arguments>
        </block>
</referenceContainer>
    </body>
</page>
1
0

According to release note, now to manage custom layout updates we should do that by creating a physical files, my question is how to do that? It’s not clear for me how to manage PageIdentifier_UpdateID and where to put the file. Thanks for your kindly help

0

I tried to create a custom layout for category:

app/design/frontend/<your_vendor_name>/<your_theme_name>/Magento_Catalog/layout/

name : catalog_category_view_selectable_3_custom.xml

Not showing at all in the category ID:3 design tab ..

Any idea ? Thank you

4
  • 3
    please check Content > Design > Configuration > Global Website is set to the theme you are adding catalog_category_view_selectable_x_custom.xml. and do not forget to clean cache.
    – Vvvaida
    Feb 24, 2020 at 15:02
  • not doing anything. I put the theme everywhere ... still can't add a custom layout.. see the link below .. nothing here : (imgur.com/a/W79QjkM) Feb 26, 2020 at 13:02
  • Please check if your xml well formed with no errors. Ir there is an error in the layout magento in production mode will not add it and just ignore it. In developer mode you will see error.
    – Vvvaida
    Feb 26, 2020 at 14:14
  • also the product sku must match with layout name like this: catalog_product_view_selectable_2200-49710-019_custom.xml when product sku is:2200-49710-019
    – Vvvaida
    Feb 26, 2020 at 14:20
0

To further expand on KAndy's answer, if you need to add layout update to cms page with url key "my-first-cms-page" then you can create file

cms_page_view_selectable_my-first-cms-page_LayoutUpdateName.xml

This file will go under app/design/frontend/<them_vendor>/<theme_dir>/Magento_Cms/layout directory.

When you go in the admin panel, under "Design" => Custom Layout Update you will see LayoutUpdateName" in the dropdown. Select and clear cache and your layout updates will be applied to the page.

1
  • Is there any possibility to remove all the CMS page header section cache?
    – Ramya
    Apr 23, 2020 at 11:32

Your Answer

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

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