2

I want to create my own custom template to choose from a CMS page in Magento 2.

I've already done the following:

Created bktext.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="2columns-left"/>
</layout>

And also layouts.xml

<?xml version="1.0" encoding="UTF-8"?>
<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
<layout id="bktext">
    <label translate="true">New text - Page</label>
</layout>
</page_layouts>

So the page is now visible from the dropdown.

But how can I now make my own design with the normal HTML markup? Just like the old version of Magento where I could edit the .phtml file with just divs and other normal markup.

Is that even possible?

Regards,

Edit:

I just want to make up a file like this:

<header>Header content with menu</header
<div class="container">
    <div class="row">
        <div class="col-md-9">
            Content from the CMS page
        </div>
        <div class="col-md-3 sidebar">
            <ul>
                <li>Text</li>
                <li>Text</li>
                <li>Text</li>
                <li>Text</li>
            </ul>
        </div>
    </div>
</div>
<footer>Footer content</footer>

Is that possible? Instead of using the blocks where I have no idea to edit the files?

0

What I understood from your question is You want to create a template file and want to use through cms from back end. If it is not this in your need please ignore it.

  • First of all you can create a cms page from back end and call directly the template file in to that cms content like

example

{{block class="Magento\Bannerslider\Block\Slideshow" template="Magento_Bannerslider::bannerslider.phtml"}}

Or if you are trying to create new custom theme for your new project just follow the below link.

Magento2 Custom theme

for custom theme

0

Try below step to create the custom layout.

Create Vendor/Module/view/frontend/layouts.xml this file for the custom layout

<?xml version="1.0" encoding="UTF-8"?>
<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
    <layout id="mylayout">
        <label translate="true">my layout</label>
    </layout>
</page_layouts>

2- Use the layout in this custom layout. Vendor/Module/view/frontend/mylayout.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="content">
    </referenceContainer>
</layout>
  • Hi Birjitsinh, Thanks for the answer, but how can I make my custom block to load with my own content? I've updated my answer also with what I exactly mean. – n00bly Nov 21 '18 at 11:49

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.