views:

3607

answers:

5

A little background:
I've been looking at a few php framework recently and it came down to 2 framework. The zend framework or Code Igniter.

I prefer CI because if it's simple design. It's very barebone and just kept it simple. But the thing I didn't like is the weak template system. The template system is important for me because I will be working with another designer being able to give him a good template system is a big plus.

Zend was the second choice because of a better template system builtin. But zend is a different beast from CI. It emphasis 'loose coupling between modules' but It is a bigger framework and I don't like to feel like i have all things things under the hood that I never use. Those are unecessary overhead in my opinion.

So I thought about putting a template system into CI, namely smarty.

So, my question is: How easy/hard is the process. From my initial scan of the CI documentation I can see that the layout of the framework is easy enough to understand and I anticipate no problems.
But I want to know if anyone of you used it before and therefore are aware of any gotchas that I don't know that is going this hard/impossible.

I also want to know if this is a good thing to do at all. Is the template system in CI enough for normal use?(which I doubt, it is very limited, you have to escape into php to do pretty much everything) Is there any other template module that is good for CI? Or am I better off with Zend Framework? In short, is any wheel being invented here?

+1  A: 

I did a quick google search and found the following: http://devcha.blogspot.com/2007/12/smarty-as-template-engine-in-code.html http://codeigniter.com/forums/viewthread/67127/

If the designer is not familiar with Smarty, I think it's almost the same as if you use the existing CodeIgniter templating system (which leaves everything to PHP actually). It also depends on the complexity of the project at hand.

You can also hook Smarty with Zend Framework. It's more complex than with CodeIgniter, but there's already a primer on how to do exactly that in the ZF documentation. http://framework.zend.com/manual/en/zend.view.scripts.html Plus lots of tutorials on the net.

In my opinion it's almost the same, you can use pure PHP or Smarty as your template "engine", so it depends on the project. Also, compare a developer who has extensive experience and already has a library of view helpers so she uses pure PHP, versus a designer who doesn't know anything about PHP, but has extensive experience with Smarty. Sometimes decisions have to be based on who is going to do what.

Favio
CI and Smarty are a match made in heaven. I use the model described in the first url.
GloryFish
+1  A: 

Slightly OT, hope you don't mind...

I'm a Zend Framework user and I think it's worth saying that the loose coupling means you don't need to include any files you're not actively using. Hopefully this negates your concern about unnecessary overhead.

With the layouts stuff added in a recent release of ZF, its templating is really hard to fault... and it's completely pluggable as Favio mentions. The more I use ZF, the more I like it; they do things the way I would do them!

Dave Gregory
+1  A: 

The CI template system is VERY lightweight. I use Smarty with my CI and it works like a charm.

I used the following forum post as a starter on getting CI implemented.

Smarty in CodeIgniter

Adam
+2  A: 

Sorry to resurrect an old question - but none of the answers have been flagged as "accepted" yet.

There's a library called "template" that does a great job of allowing you to use just about any template parser you want:

Template CI Library - Parsers

The syntax is pretty easy for integrating into your CI application and the smarty integration spot on.

JayTee
A: 

Check out this custom CodeIgniter templating library. I've already used it on several projects and it is easy to use. I know this post is late but it's worth checking out.

Randell