![]() |
avoiding redundancy - 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: avoiding redundancy (/showthread.php?tid=10989) |
avoiding redundancy - El Forum - 08-21-2008 [eluser]belbek[/eluser] suppose in one controller 'shop' I have 3 functions 'item1,2,3' each of them gives to view file information about 3 items: http://localhost/shop/item1,2,3 and I need a block wich will show information about 4th item and it should be placed on every page together with 3 previous items. how to avoid redundancy and not to place information about 4th item in each of 1-3 functions? avoiding redundancy - El Forum - 08-21-2008 [eluser]Randy Casburn[/eluser] in the __controller() do.. Code: $fourthviewdata = array('stuff'=>'my fourth view data'); Then in 1,2,3 load your views with fourth Code: $this->load->view('firstview',$this->data); then in your 1,2,3 views do Code: <?=$fourth_item_view?> where you want the block --- There you have it, Randy avoiding redundancy - El Forum - 08-21-2008 [eluser]belbek[/eluser] Thank you very much Randy. avoiding redundancy - El Forum - 08-21-2008 [eluser]Randy Casburn[/eluser] You are very welcome! |