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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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