0

I'm making a Megamenu Module, where I want to include the phtml of a file in my MailChimp module (Signup Form). Is there a way I can call on this template from within another module?

  • which magento version are you using ? – Naveed Asim Sep 27 '18 at 10:23
  • Please specify magento version – Amit Bera Sep 27 '18 at 10:24
  • Sorry I forgot! Question is edited with the version. – Digitaq Sep 27 '18 at 10:25
3

Definitely, you can call any PHTML file from another PHTML file or layout file:

To call phtml from phtml file, use below syntax:

echo $this->getLayout()->createBlock("Namespace\Module\Block\BlockClass")->setTemplate("Namespace_Module::filename.phtml")->toHtml();

or you can even try:

<?php include ($block->getTemplateFile('Namespace_Module::/foldername/filename.phtml')) ?>
| improve this answer | |
1

Yes you can include / add other's module template in different module. in your module's layout file add block like that :

 <block class="other\module\block\class" name="mail.chimp.template" template="Mail_Chimp::template.phtml" />

here :

class="other\module\block\class", will be other module block class.

template = "Module_Name/template_file.phtml"

| improve this answer | |
0

Sure you can. In your layout xml, specify the module see below (where vendor i will assume it's MailChimp:

<block class="YourBlock" name="your.name" template="Vendor_module::path/template.phtml" >
| improve this answer | |

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.