CodeIgniter Forums
CI4: How to run modules in views? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: CI4: How to run modules in views? (/thread-73425.html)



CI4: How to run modules in views? - Avega Soft - 04-23-2019

Hi every! I have question - how calling Modules methods in views in CI4? For example in CI3 + HMVC, i am writing this line code "modules::run('blog/posts/get_posts', 10);" it returns array of posts. But how to do it in CI4 a can't found in manual ( https://codeigniter4.github.io/userguide/general/modules.html?highlight=modules ) and this post ( http://blog.newmythmedia.com/blog/show/2016-03-15_Modules_in_CodeIgniter_4 ) not help too.


RE: CI4: How to run modules in views? - kilishan - 04-23-2019

I believe what you're looking for are our View Cells.


RE: CI4: How to run modules in views? - Avega Soft - 04-23-2019

(04-23-2019, 06:35 AM)kilishan Wrote: I believe what you're looking for are our View Cells.

Yes. I've read about view_cell. It's a good decision, but this function returns the generated HTML as a string. But I've needed data array, not as string (HTML). Maybe are there any other variants? Thanks for answering.


RE: CI4: How to run modules in views? - kilishan - 04-23-2019

Whatever you call in the cell can generate the HTML. Use a view partial for whatever you want to display and generate that within the modules method, then return the generated HTML to cell.

That's the only variant we have, but that should work, right?


RE: CI4: How to run modules in views? - Avega Soft - 04-23-2019

(04-23-2019, 10:44 AM)kilishan Wrote: Whatever you call in the cell can generate the HTML. Use a view partial for whatever you want to display and generate that within the modules method, then return the generated HTML to cell.

That's the only variant we have, but that should work, right?

Yes this variant with view_cell good work for me too. Maybe I'm just used to CI3+HMVC and think by the standards of this version. Thanks a lot for clarification about this functional. P.S. I'm waiting for your book https://leanpub.com/codeigniter4foundations. I hope is coming soon)