News and statistics in the left column - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: News and statistics in the left column (/showthread.php?tid=13808) Pages:
1
2
|
News and statistics in the left column - El Forum - 12-08-2008 [eluser]got 2 doodle[/eluser] Great glad you have a solution I tried this and it worked In parent controller Code: function Site_Controller() home.php does not make any reference at all to $sample array or $test_two variable in view Code: <?php echo $test_two ?> outputs 'test two' doodle News and statistics in the left column - El Forum - 12-08-2008 [eluser]Bikun[/eluser] Great! It really works. Will use your solution. Thanks a lot. News and statistics in the left column - El Forum - 12-08-2008 [eluser]got 2 doodle[/eluser] We all learn together around here, your welcome. doodle News and statistics in the left column - El Forum - 12-09-2008 [eluser]sl3dg3hamm3r[/eluser] I wouldn't mess around too much with globals. Stick to class-members, make data a member: Code: class SiteController extends Controller { In the child class, you also need to write $this->data... Not tested, but should work like that... News and statistics in the left column - El Forum - 12-09-2008 [eluser]crumpet[/eluser] you will need to change all your $data vars to $this->data if there is no $this in front of a variable then it is only registered in the namespace of hte function not hte whole class you need $this to share it between class functions Also unless your header and footer are always changing you should set them in the same function as news so you don't have to set them everytime otherwise your controllers will get cluttered with writing the same code over and over again. remember the constructor of SiteController runs before the functions so you can always change thigns later you can just set default values for your templating variables there so you don't have to write as much code |