5

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?

6

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

| improve this answer | |
  • 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 at 22:34
  • 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 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 at 6:50
6

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".

| improve this answer | |
  • 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 at 22:35
  • it's working properly. – Magento Learner Apr 16 at 12:07
  • @DustinW Thank you, your comment helped me a lot! – Hannes Schneidermayer Jun 4 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 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 – Erik Hansen Sep 15 at 16:41
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

| improve this answer | |
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

| improve this answer | |
  • 1
    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 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) – Clément CREUSAT Feb 26 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 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 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.

| improve this answer | |
  • Is there any possibility to remove all the CMS page header section cache? – Ramya Apr 23 at 11:32
0

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>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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