cancel
Showing results for 
Search instead for 
Did you mean: 

Custom lay-out update after new Magento version

Custom lay-out update after new Magento version

Hi,

I am running Magento 2.3.5-p1, but it is not possible to add a custom layout update anymore on my CMS page. For example I would like to add a code like this:

 

<reference name="content">
   <block type="cms/block" name="additional.info" as="additionalInfo">
      <action method="setBlockId"><id>additional_info</id></action>
   </block>
</reference>

Since the new Magento version, there is only a dropdown, in stead of a blank field where I can add something.

 

How can I use this code in the new Magento version?

 

12 REPLIES 12

Re: Custom lay-out update after new Magento version

Hi @alexander_jorda ,

 

As of the latest Magento versions, merchants can select layout updates to be applied to specific Category/Product/CMS Page pages on the frontend. These layout updates are made by creating layout XML files following specific naming conventions.

 

For CMS Pages:

cms_page_view_selectable_<CMS Page Identifier>_<Layout Update Name>.xml

where:

  • CMS Page Identifier is the desired page’s URL Key with “/” symbols replaced with “_”
  • Layout Update Name is what is shown as the option for Custom layout update field of Design section on CMS Page Edit page

These files must be placed in the appropriate folders for layout XML files. They will be available as Custom Layout Update options for Merchants after flushing the cache.

 

DevDocs: https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/xml-manage.html#create-cms-pagepr...

 

Thanks!

-------------------------------------------------------------

Problem Solved! Click Kudos & Accept As Solution.

Re: Custom lay-out update after new Magento version

Thanks for your answer. Where do I need to put those new xml files? I do not have this path for example:

 

app/code/Vendor/Module/view/frontend/layout/catalog_product_view.xml

 

Re: Custom lay-out update after new Magento version

I found it already.

 

  1. Category or Product: app/design/frontend/ <Vendor>/<Theme> /Magento_Catalog/layout/ E.g.: app/design/frontend/Olegnax/Athlete2/Magento_Catalog/layout/
  2. CMS Page: app/design/frontend/<Vendor>/<Theme>/Magento_Theme/layout/

For a block you need to use:

<referenceContainer name="content.bottom">
    <block class="Magento\Cms\Block\Block" name="block_identifier">
        <arguments>
            <!-- Here is the CMS Block id -->
            <argument name="block_id" xsi:type="string">my_cms_block_identifier</argument>
        </arguments>
    </block>
</referenceContainer>

Re: Custom lay-out update after new Magento version

This is what I have used now, but the sidebar block is on the bottom of the left side. How can this be displayed on the upper left side?

 

<?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="sidebar.main">
<referenceBlock name="sidebar.additional">
<block class="Magento\Cms\Block\Block" name="sidebar_customer-service">
<arguments>
<!-- Here is the CMS Block id -->
<argument name="block_id" xsi:type="string">sidebar_customer-service</argument>
</arguments>
</block>
</referenceBlock>
</referenceContainer>
</body>
</page>

Re: Custom lay-out update after new Magento version

Hi @alexander_jorda ,

Can you please replace your XML code with the below code and flush the Magento cache after the changes.

<referenceContainer name="sidebar.additional">
     <block class="Magento\Cms\Block\Block" name="mycustomstaticblock">
        <arguments>
            <argument name="block_id" xsi:type="string">static_block_id</argument>
        </arguments>
    </block>
</referenceContainer>

Thanks!

-----------------------------------------

Problem Solved! Click Kudos & Accept as Solution!

Re: Custom lay-out update after new Magento version

This is exactly my code..

 

<referenceContainer name="sidebar.main">
<referenceBlock name="sidebar.additional">
<block class="Magento\Cms\Block\Block" name="sidebar_customer-service">
<arguments>
<!-- Here is the CMS Block id -->
<argument name="block_id" xsi:type="string">sidebar_customer-service</argument>
</arguments>
</block>
</referenceBlock>
</referenceContainer>

Re: Custom lay-out update after new Magento version

<referenceContainer name="sidebar.additional">
<block class="Magento\Cms\Block\Block" name="sidebar_customer-service">
<arguments>
<!-- Here is the CMS Block id -->
<argument name="block_id" xsi:type="string">sidebar_customer-service</argument>
</arguments>
</block>
</referenceContainer>

Re: Custom lay-out update after new Magento version

Hi @alexander_jorda ,

 

In your code, if you are using 2 tags (referenceContainer, referenceBlock)

then please try to use only one tag as I used in my code.

Please follow the below link: 

 

https://magento.stackexchange.com/questions/219041/how-insert-static-block-all-cms-page-sidebar-left...

 

Thanks!

---------------------------

Problem Solved! Click Kudos & Accept as Solution.

Re: Custom lay-out update after new Magento version

Hi,

I have copy/paste your code. Please see the code I am using now:

 

       <referenceContainer name="sidebar.additional">
           <block class="Magento\Cms\Block\Block" name="sidebar_customer-service">
               <arguments>
                   <!-- Here is the CMS Block id -->
                   <argument name="block_id" xsi:type="string">sidebar_customer-service</argument>
               </arguments>
           </block>
       </referenceContainer>

But still the sidebar is in the left bottom.