Repeating, my own function, how? - 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: Repeating, my own function, how? (/showthread.php?tid=8293) |
Repeating, my own function, how? - El Forum - 05-13-2008 [eluser]Gewa[/eluser] Hi, I am making a web-site , and I liked so much CI. Thank you guys for this excellent tool Please advice such thing. In each controller, in constructor place I am putting such code Code: class Content extends Controller { Which displays Header, Left Peace of web-site with left menu.... Can you tell me the way, how can I make header() function or something like $this->bla-bla->header() that can i put once, instead of this huge code each time? Where to create this function, and where to put... thanks Repeating, my own function, how? - El Forum - 05-13-2008 [eluser]Pascal Kriete[/eluser] You would could create a library. Code: class Layout { Name that file layout.php and plop it in your application/libraries folder. To use, autoload 'layout' and in your constructors do: Code: $this->layout->show_header(); Obviously you can add functions as your heart desires. Here's some complimentary reading. Hope that helps. Repeating, my own function, how? - El Forum - 05-15-2008 [eluser]Gewa[/eluser] thank you SOOOOOOOOOOOOOOOOOOOOOOOOO Much! |