Jump to content

custom template class


Julius

Recommended Posts

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...

Link to comment
https://forums.phpfreaks.com/topic/226807-custom-template-class/
Share on other sites

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 : )

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.