Explantion of {elapsed_time} - 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: Explantion of {elapsed_time} (/showthread.php?tid=23927) |
Explantion of {elapsed_time} - El Forum - 10-26-2009 [eluser]Grind[/eluser] If you download Codeigniter and view the welcome_message.php file you see at the bottom of the page the following code: Code: Page rendered in {elapsed_time} seconds Where does {elapsed_time} refer to? Is it possible to make such thing for displaying a guestbook, like {guestbook}? Thanks. Explantion of {elapsed_time} - El Forum - 10-26-2009 [eluser]rogierb[/eluser] Check out the benchmarking class in the userguide. You will find the answer there. Explantion of {elapsed_time} - El Forum - 10-26-2009 [eluser]Grind[/eluser] Thanks. I now understand the elapsed time-bit. But is it possible to make a pseudo-variable for a guestbook? This would dramatically decrease the amount of PHP-code in the view-file. Explantion of {elapsed_time} - El Forum - 10-26-2009 [eluser]rogierb[/eluser] You can if you extend the output class. But that might not be the best option, why not use a 'normal' variable to pass to the view? Explantion of {elapsed_time} - El Forum - 10-26-2009 [eluser]Grind[/eluser] Could it be achieved with one variable then? Now I have a foreach-loop in the view-file to display the guestbook, but that amount of PHP-code could be less? Where can I find how I do this? I'm still learning Codeigniter. Explantion of {elapsed_time} - El Forum - 10-26-2009 [eluser]rogierb[/eluser] Just cut the php code from your view, stick it in the controller (method) and put is in a variable. Then pass it to the view. Code: private function guestbook() Explantion of {elapsed_time} - El Forum - 10-26-2009 [eluser]Grind[/eluser] Thanks for your reply. That's a lot better. But it doesn't work for a 100%. My guestbook-function looks something like this: Code: private function guestbook() But the guestbook is shown, even if the variable $guestbook isn't echoed in the view-file. Besides, the guestbook-function is echoed before loading the page. So if I look at the source I see all the guestbook-entries and after that the <html> and <head>-tags etc. So something is wrong. I think I don't need to echo anything in the guestbook-function, but how does it work instead? Thanks for your help. Explantion of {elapsed_time} - El Forum - 10-26-2009 [eluser]rogierb[/eluser] hi, Don't echo in your controller, only in a view files. If you echo in you controller, you output before the headers and html. Code: $guestbook .= "<h3>".$row->name.'</h3>'; Explantion of {elapsed_time} - El Forum - 10-26-2009 [eluser]Grind[/eluser] How obvious. Thank you very much! |