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?

1 Answer 1

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
  • In module A my value paste.ofcode.org/Ene6SkjRfY3vCCkeCcDADK
    – zus
    Commented Apr 30, 2021 at 12:36
  • How to share storeCode to my module B
    – zus
    Commented Apr 30, 2021 at 12:37
  • You can pass data using array format.
    – Jayesh
    Commented Apr 30, 2021 at 12:39
  • Can i get some code help?
    – zus
    Commented Apr 30, 2021 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.