Loading dynamic content into blockviews - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Loading dynamic content into blockviews (/showthread.php?tid=40489) |
Loading dynamic content into blockviews - El Forum - 04-10-2011 [eluser]Svante Hansson[/eluser] I'm in the process of converting a old sluggish website to using the CI framework. I've currently stripped down the frontpage into 8 views (header, previous article, highlight, adblock and so on) so I can just include them whenever I want to use them (depending on page). I'm trying to figure out the best way of populating those views without having to clutter up the controller with 4~ new modules everytime I load a page. I would like some way of loading the view with some sort of default data that's loaded from the database. Any ideas? Kind regards, Svante Loading dynamic content into blockviews - El Forum - 04-10-2011 [eluser]oppenheimer[/eluser] Have you thought about using the third parameter of the $this->load->view to load each block into a variable? Code: $page['header'] = $this->load->view('header',$data,true); You can load $data with any information from the DB that you want that view to display. Then you need an overall view that pulls it all together and displays it. Code: $this->load->view('layout',$page); Code: <?php Loading dynamic content into blockviews - El Forum - 04-10-2011 [eluser]John_Betong_002[/eluser] In addition to the above I would add the HTML layout Divs and endeavour to not have any HTML script in the "Partial Views": Code: <!doctype html> Loading dynamic content into blockviews - El Forum - 04-10-2011 [eluser]Svante Hansson[/eluser] An excerpt of the page just do see how bloody much divs to keep track :p Sometimes it's not even impossible not splitting up parts of the same div. It's so nested. Thanks for the replies so far! Code: <div id="page-bg"> Loading dynamic content into blockviews - El Forum - 04-10-2011 [eluser]InsiteFX[/eluser] Code: $page['header'] = $this->load->view('header'); InsiteFX |