Julius Posted February 5, 2011 Share Posted February 5, 2011 hello, I have tried to build a website on codeigniter, then i thought I shouldn't use a framework because then I would learn php better. And heres a problem: on codeigniter, to load a template file all I had to do was write this line $this -> load -> view ( 'somefile.php' ); now when i can't use this, i googled for some php template classes/engines, and didn't find any like codeigniter had. I want to load the file like $this -> load ( 'file.php' ); or similar, because now I have to write much more lines and it's pretty confusing ( $template = new Template ( 'file.php' ); the operations with it, and if my header/footer is separated from main content it gets pretty messy.). Can anyone help me to write my own template class? Sorry for bad English... Quote Link to comment Share on other sites More sharing options...
lastkarrde Posted February 6, 2011 Share Posted February 6, 2011 You'll find quite alot of tutorials on the web if you search for 'php templating system tutorial'. Unfortunately most aren't that great. You'll spend alot more time coding the template engine to be perfect than actually using it. I highly recommend the PHP templating engine Twig. The code is well written and is fully featured (inheritance, caching, filters). You can use Twig in frameworks (Code Igniter, Kohana, ZF etc..) or just in your own project. The API is extremely simple and performance is extremely fast : ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.