0

In custom modules, I want to share my module A output variable $value = "one" to module B, print like $value How to share this?

0

You can use the setData() & getData() function.

Step: 1

Module A Add below code in Module A phtml file

A.phtml

$data = array('value'=> 'one');

<?php echo $this->getLayout()->createBlock("VendorName\ModuleName\Block\CustomBlock")->setData($data)->setTemplate("VendorName_ModuleName::path/B.phtml")->toHtml(); ?>

Step: 2

Module B Add below code in Module B phtml file

B.phtml

$value = $this->getData('value ');
4

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.