![]() |
__destruct and outputting views - 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: __destruct and outputting views (/showthread.php?tid=14797) |
__destruct and outputting views - El Forum - 01-15-2009 [eluser]TheLizardKing[/eluser] I am trying to output a view using PHP5's __destruct in an attempt to create a header/content/footer setup. Code: <?php When ran my output is always the content of common/header.php then links/hot.php then nothing. I can echo out text in my destructor but my view never outputs. I know the view is good because I can place it anywhere else. Am I mistaken on how the destructor works? What is a good work around? __destruct and outputting views - El Forum - 01-15-2009 [eluser]drewbee[/eluser] I think your problem is the fact that the views output is ran before __destruct() happens. You will have to force Code Igniter to not use its own output, and rather force it out on your own. I know how to output code igniters current setup, however telling it not to output its own data is a mess regardless. Code: function __destruct() Why not load the footer view within the links/hot. This way you are not calling this in your controller, but the view ie links/hot.php (view) Code: echo $this->load->view('header', TRUE); I am not sure if that will work or not, but that would be my best method for doing this. Personally, I just create one global_view file. __destruct and outputting views - El Forum - 01-15-2009 [eluser]TheLizardKing[/eluser] HMM, I think I'll use your header/footer in the view advice. Thanks! __destruct and outputting views - El Forum - 01-15-2009 [eluser]nikefido[/eluser] isn't destruct only called when an object is "destroyed" ? __destruct and outputting views - El Forum - 01-16-2009 [eluser]TheLizardKing[/eluser] Well destroyed or execution of the object is complete. You can test it by throwing an echo into the destructor and seeing if it outputs. |