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?

asked Nov 9, 2016 at 6:54
7
  • You can add layout xml code to particular cms pages from admin. open cms page which you want to update, you can add. Commented Nov 9, 2016 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 Commented Nov 9, 2016 at 9:12
  • Which page you need to it ? Commented Nov 9, 2016 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. Commented Nov 9, 2016 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. Commented Nov 9, 2016 at 9:36

1 Answer 1

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.

answered Nov 9, 2016 at 7:23
1
  • 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? Commented Nov 9, 2016 at 9:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.