문제

I have added a static CMS bock by set up patch, so I will now put it in a specific area like in cart information pop up or a different layout like payment checkout before payments methods.

Update:
I want to do it through code.

도움이 되었습니까?

해결책

<referenceContainer name="content">
  <block class="Magento\Cms\Block\Block" name="unick_block_name">
    <arguments>
      <argument name="block_id" xsi:type="string">your_block_identifier</argument>
    </arguments>
  </block>
</referenceContainer>

use this to add a static block via layout XML file

AND

<?php
echo $this->getLayout()
->createBlock('Magento\Cms\Block\Block')
->setBlockId('your_block_identifier')
->toHtml();
?>

use this to add a static block via .phtml file

And If you want it to display it on the HTML template page then store it in variable and pass it via x-init config option part then display it html bind use in KO

HTML template part I have never done but this is the possible way I believe that work

다른 팁

without any code intervention, what you could try is to create a new widget with CMS block type (https://docs.magento.com/user-guide/cms/widget-create.html) and set it to be displayed on 'specified page' - choose your page and see if in the 'container' dropdown you find any default option that suits your needs.

good luck!

<?xml version="1.0" encoding="UTF-8"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="vendor_module::css/advancelayoutmanagement.css" />
    </head>
    <body>
        <referenceContainer name="page.wrapper">
            <block class="vendor\module\Block\Widget\EditButton" before="header.container" name="add-new-header-link" template="vendor_module::widget/edit_button.phtml">
            </block>
        </referenceContainer>
    </body>
</page>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top