質問

I have created a page using the CMS (via Admin Portal) and now I want to add a custom block (programmed) to the page. You can see the created page here: enter image description here

My structure is the following:

enter image description here

but unfortunately I do not get the created CMS page with the block connected. I thought that maybe the Router ID has to be set to cms. But I don't know exactly how to adjust the files accordingly. Do you have any ideas?

役に立ちましたか?

解決

Using module you can add your block like this.

Add in your layout file

summary_index_index.xml

<?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="content">
             <block class="VenAbf\ModAbf\Block\Index" name="call_block_name" template="VenAbf_ModAbf::testinase.phtml" />
        </referenceContainer>
    </body>
</page>

Using admin panel go to you cms page and click on edit and add this line and click on save

{{block class="VenAbf\ModAbf\Block\Index" template="VenAbf_ModAbf::testinase.phtml"}}

Please run magento command after adding above code.

php bin/magento s:up
php bin/magento s:s:d -f
php bin/magento c:f

I Hope This Helps You.

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top