0

I try to define the new design layout and call the left sidebar in cms pages. enter image description here

What I do: app/design/frontend/Vendor/Theme/layout01/Magento_Theme/layout/layouts.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
    <layout id="customer_services">
        <label translate="true">Customer Service Page</label>
    </layout>
</page_layouts>

Now: app/design/frontend/Vendor/Theme/layout01/Magento_Theme/page_layout/customer_services.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
    <update handle="1column"/>
    <referenceContainer name="main" htmlClass="column main col-md-10"/>
    <referenceContainer name="columns">
    <container name="col-sidebar" htmlTag="div" htmlClass="col-md-2" before="main">
        <block class="Magento\Cms\Block\Block" name="customer.services.menu" before="-">
            <arguments>
                <argument name="block_id" xsi:type="string">customer-services-menu</argument>
            </arguments>
        </block>
        <block class="Magento\Cms\Block\Block" name="customer.services.block2" after="customer.services.menu">
            <arguments>
                <argument name="block_id" xsi:type="string">customer-services-block2</argument>
            </arguments>
        </block>
    </container>
    </referenceContainer>
</layout>

Now I created a new block with ID:

customer-services-menu

After refreshing cache Still I did not see any new design layout: enter image description here

2 Answers 2

0

If you want to call static block on page

Try below code :

{{block class="Magento\\Cms\\Block\\Block" block_id="block_identifier"}}

If you want to call in phtml file :

Try below code :

<?php echo $block->getLayout()->createBlock(\Magento\Cms\Block\Block::class)->setBlockId('block_identifier')->toHtml();?>

Your xml file code should be :

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

At Last, if you want to call phtml with your block in cms page:

Try below code :

{{block class="Magento\Modulename\Block\Blockname" template="Magento_Modulename::templatefilename.phtml"}}

Refer to this link for more details - https://chetansanghani.wordpress.com/2015/11/20/magento2-display-static-block-in-phtml-file-cms-page/

0

You need to update the below code

app/design/frontend/Vendor/Theme/Magento_Theme/page_layou/customer_services.xml
<?xml version="1.0"?>
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
    <update handle="1column"/>
    <referenceContainer name="page.wrapper">
        <container name="header.container" as="header_container" label="Page Header Container" htmlTag="header" htmlClass="page-header" before="main.content"/>
        <container name="page.top" as="page_top" label="After Page Header" after="header.container"/>
        <container name="footer-container" as="footer" before="before.body.end" label="Page Footer Container" htmlTag="footer" htmlClass="page-footer"/>
    </referenceContainer>
    <referenceContainer name="main" htmlClass="column main col-md-10"/>
    <referenceContainer name="columns">
        <container name="col-sidebar" htmlTag="div" htmlClass="col-md-2" before="main">
            <block class="Magento\Cms\Block\Block" name="customer.services.menu" before="-">
                <arguments>
                    <argument name="block_id" xsi:type="string">customer-services-menu</argument>
                </arguments>
            </block>
            <block class="Magento\Cms\Block\Block" name="customer.services.block2" after="customer.services.menu">
                <arguments>
                    <argument name="block_id" xsi:type="string">customer-services-block2</argument>
                </arguments>
            </block>
        </container>
    </referenceContainer>
</layout>

check now your Customer Service Page is showing

enter image description here

In frontend also applied Customer Service Page

enter image description here

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.