2

From a previous question I learned how to add some static blocks to the CMS homepage like this: how to achieve this 2 columns page layout?

The xml is created in:

app/design/frontend/<Vendor>/<theme>/Magento_Cms/layout/cms_index_index.xml

Now if I want to have the same for other new created CMS page how to achieve that?

What would be the name for the xml file? I have tried things like cms_contact_contact.xml but that did not work?

Any suggestions?

  • You can add layout xml code to particular cms pages from admin. open cms page which you want to update, you can add. – Suresh Chikani Nov 9 '16 at 7:08
  • I know that way but as referred to, I would like to achieve that trough a xml file such as cms_index_index.xml – mr_typo3 Nov 9 '16 at 9:12
  • Which page you need to it ? – Suresh Chikani Nov 9 '16 at 9:21
  • That does not matter so much. Just a (new created) cms page. See the example I referred to in my above question. – mr_typo3 Nov 9 '16 at 9:29
  • Then you have to include on every page and display it conditionally if page is cms, block is display other wise not display. – Suresh Chikani Nov 9 '16 at 9:36
2

You can directly add static block to cms page.

In backend, go to

Content -> CMS Page

Click on specific CMS page,

inside page,

go to Design Tab,

Set Layout Update XML code,

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

In above xml code, Replace static_block_id with your block id. Remove cache and check for specific page.

Your Block content are display only specific page.

  • I understand but its not an question to my answer. I would like to know how to get that through a xml file similar as cms_index_index.xml which is only applied to the cms homepage ? So how to get a similar xml.file which will be used by a specific named cms-page? – mr_typo3 Nov 9 '16 at 9:16

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.