![]() |
View Component - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: View Component (/showthread.php?tid=84595) |
View Component - SubrataJ - 10-22-2022 is there any way we can make a reusable component of a specific part of HTML and use it throughout the application? I have heard rumors that it is possible but I have had a hard time finding an article on the same on the web. Thank you in Advance, Keep Grinding ![]() RE: View Component - captain-sensible - 10-22-2022 if you use the approach of "layout" in your views , then you can create for want of a better word , chunks of html which can be inserted into a single main web page So in my case my view "layout" contains the header(with links to css , bootstrap etc ) , main middle section where different content is inserted and footer(also containing jquery ) in the middle it has Code: <?= $this->renderSection('content') ?> each different "chunk" of html will be in the form : Code: <?= $this->extend('layout') ?> RE: View Component - kenjis - 10-22-2022 CI4 has View Cells. See https://codeigniter4.github.io/CodeIgniter4/outgoing/view_cells.html RE: View Component - SubrataJ - 10-22-2022 @captain-sensible thanks for the reply but I am already aware of the rendersection.. Thank you @kenjis for now this looks pretty promising to me after going through the documentation. i will give it a shot RE: View Component - kilishan - 10-24-2022 Cells and layouts are both parts of the puzzle. If you don't need any logic with the HTML chunks, you could just store them as a separate view and include them wherever you need them. RE: View Component - SubrataJ - 10-25-2022 (10-24-2022, 06:52 AM)kilishan Wrote: Cells and layouts are both parts of the puzzle. If you don't need any logic with the HTML chunks, you could just store them as a separate view and include them wherever you need them. Thanks for the insights. |