5

I have custom module in which there is custom block and it's associated phtml which call my custom block functions using $block object.

I want to call other module block function in my custom module phtml

So I need to figure out the best way of doing it? I already have the idea how to call other block function in phtml through Objectmanager but it is not the best practice

Any help, knowledge and experience sharing would be appreciated

5

You Can Call Another Module Block Like This :-

$block = $this->getLayout()->createBlock('\Vendor\Module\Block\File')->yourFunction();
|improve this answer|||||
  • Let me try this, come back to you :) – Muhammad Hasham May 21 '19 at 6:00
  • It worked. Thanks :) – Muhammad Hasham May 21 '19 at 6:17
  • Welcome.. Happy Coding :) – Rk Rathod May 21 '19 at 6:19

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.