Magento 2 : Call PHTML file In CMS page and XML / Text in PHTML file

Posted: October 29, 2016 in Magento

Call PHTML file In CMS page:

{{block class="Magento\Framework\View\Element\Template" name="test_file" template="Magento_Theme::html/test.phtml"}} 

Call PHTML file in XML:

<referenceContainer name="footer">                
            <block class="Magento\Framework\View\Element\Template" name="footer.hcontent" template="Magento_Theme::html/footer.phtml">
                <container name="hcontent" label="footer content"/>
            </block>
</referenceContainer>

Text in PHTML file:

<?php echo __('Create Backup') ?>

If your string contains a variable, to add a placeholder for this variable in the dictionary, use syntax similar to the following:

<?php echo sprintf(__('Hello %s'), $yourVariable) ?>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s