Magento – How to Call PHTML File in Static Block

formsphtmlstatic-block

I have created phtml file,

app/design/frontend/Smartwave/porto/Magento_Contact/templates/inquiry.phtml

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile
/** @var \Magento\Contact\Block\ContactForm $block */
?>
<form>
  <div class="form-group">
    <label for="Full Name">Full Name:</label>
    <input type="text" class="form-control" id="name">
  </div>

  <div class="form-group">
    <label for="company name">Company Name:</label>
    <input type="text" class="form-control" id="companyname">
  </div>

<div class="form-group">
    <label for="email id">Email Id:</label>
    <input type="text" class="form-control" id="emailid">
  </div>

<div class="form-group">
    <label for="contact number">Contact Number:</label>
    <input type="text" class="form-control" id="contactnumber">
  </div>

<div class="form-group">
    <label for="product name">Product Name:</label>
    <input type="text" class="form-control" id="productname">
  </div>

<div class="form-group">

  <label for="comment">Comment:</label>
  <textarea class="form-control" rows="5" id="comment"></textarea>
</div>
  <button type="submit" class="btn btn-default">Submit</button>
</form>
</form>

and call this file in a static block in the backend

<p>{{store url="inquiry-page"}}</p>
{{block class="Magento\Framework\View\Element\Template" template="porto/Magento_Contact/inquiry.phtml"}}

but only <p>{{store url="inquiry-page"}}</p> is working. Phtml block in not calling up

Best Answer

Try this piece of code in your static block.

{{block class="Magento\Contact\Block\ContactForm" name="inquiry.form"  template="Magento_Contact::inquiry.phtml"}}