Introducing the Template Library |
[eluser]Colin Williams[/eluser]
Hey all! I'm excited, after weeks of preparation and months of iterative tweaking, to finally release my first full contribution to the CodeIgniter community: The CodeIgniter Template library. Template Library homepage The Template library, written for the CodeIgniter PHP-framework, is a wrapper for CI’s View implementation. Template is a reaction to the numerous questions from the CI community regarding how one would display multiple views for one controller, and how to embed “views within views” in a standardized fashion. In addition, Template provides extra Views loading capabilities and shortcuts for including CSS, JavaScript, and other common elements in your final rendered HTML. Using Template looks like this: Code: $this->template->write('title', 'Introduction to Template'); Look interesting? Head over to the Template Library homepage to begin using Template in your next CodeIgniter application. Well, it's late and the sleeping pills are kicking in, so I hope I haven't overlooked anything in this release. I'll be around for support, of course. Cheers! ;-P
[eluser]Adam Griffiths[/eluser]
This looks great. I may use it in my current project. Kudos on the detailed user guide!
[eluser]johnwbaxter[/eluser]
Loving the name, i personally can't stand stupid names for stuff. Having used joomla a fair bit it looks pretty stupid when you have http://joe.com/index.php?com_ilovecowsforms in your urls.
[eluser]Michael Wales[/eluser]
Quote:http://joe.com/index.php?com_ilovecowsforms404 ![]() In all seriousness, with CI it doesn't matter what the library is called - you generate your own URLs.
[eluser]johnwbaxter[/eluser]
Of course it was a fake url and also a made up joomla component! I know it doesn't matter with CI (i do know a little bit about ci...!) but it still irks me.
[eluser]Colin Williams[/eluser]
Quote:Kudos on the detailed user guide! Your welcome! It actually took longer, much longer, to finish than the library. Also, writing it exposed problems with the code and ideas for more features. It's a good exercise that serves everybody well. Quote:Loving the name, i personally can’t stand stupid names for stuff. Amen. Like I state in the user guide, I wanted it to read well when encountered in the code. Although it is important at times to have more unique, less generic naming standards in big communities, I think I can still get away with it here. There currently is an exactly named library in the Wiki that does something quite different.
[eluser]Bramme[/eluser]
Okay, I thought I'd use this, seeing as I didn't really like my current way of working and now I have to deal with a multi controller application I thought this would really help me. But I just can't get it to work. It's probably something stupid, but here goes nothing. I left the config file as it was, only changed the standard view file template.php into index.php which looks like this: Code: <?php Now I've put this in my controller construct: Code: $this->template->load(); Also, a feature request: you can pass content (in an array) in the config file, wouldn't it be handy if we could pass it view files too? Edit: Okay, I feel stupid, didn't look at the example properly, now it's working like a charm. Didn't need to do the load thing in the construct, needed to do it LAST (not first) in my preferred method, only need to write to header and footer in the construct.
[eluser]Colin Williams[/eluser]
Glad you solved it, bramme. The docs could be a little more clear on how important the load() method is and what it does. It is the final step, taking all your regions and sending them to the master template.
[eluser]Bramme[/eluser]
Yeah, I think I could confused because you first talk about template->load. Load is most of the time a command you use first in CI. Maybe you could/should rename to something like "initiate"? Though that's often used second. Tough one... Anyhoo, what about my feature request? I can imagine it's not that difficult? Maybe add a fifth array key for the config, view? |
Welcome Guest, Not a member yet? Register Sign In |