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:
$this->template->write('title', 'Introduction to Template'); $this->template->write_view('content', 'blog/posts', $this->blog->get_posts()); $this->template->render();
Look interesting? Head over to the Template Library Homepage to begin using Template in your next CodeIgniter application.
Interesting to see that your template library works in almost the same fashion as my View Object (see signature) except the View Object can use arrays to specify the data and which view partials to load. In addition the View Object can also store other objects (libraries or modules) which may also render a view partial.
$this->view->data(array( //load global data for the page 'title' => 'Login::', 'username' => $this->validation->username, 'password' => '', 'checked' => '', 'message' => '<span class="err">'.$message.'</span>', 'action' => site_url().'login/'.$path, 'lost_pwd' => site_url().'register/lost-pwd', 'catcode' => 0, ));
$this->view->load(array( //load the view partials 'header' => 'header', 'menu' => & $this->menu, //the menu object will render its own partial 'content' => 'login/form', 'footer' => 'footer', ));
$this->view->render();
It looks like your originality is just a difference in class names.
Yeah, wiredesignz, I came across your View Object library recently and wasn’t really surprised that these issues had been tackled before. Our approaches here are similar, but they do find their differences (and they’re easy to spot, especially in the workflow and implementation). Some members here noted that my load() method was a bit confusing, so I changed it to render(), which it turns out View Object uses too.
I think I took a different approach to documentation as well. Regardless, I intend to continue developing and supporting this contribution. I hope it helps some people, and that is all I would also encourage people to compare it to View Object and decide what works best for them.
It looks like your originality is just a difference in class names.
I would, again, stress that people look at both contributions and decide if this is an accurate assessment.
first of all congratulations for this library, it really completes the CI toolset
from Template user guide:
While, yes, I could have come up with a unique, cutesy, silly name for Template, I feel such a move wouldn’t be very beneficial for those who use it
Please keep this name and don’t be tempted by funny and silly names.
@wirezdesign
It looks like your originality is just a difference in class names.
starting from elementary school we’ve been told that the same result may be achieved in several ways.
i just think that your innuendo is out of place (and time)
first of all congratulations for this library, it really completes the CI toolset
Thanks for those kind words, ralf57! I have certainly found it a nice addition on the several projects I have employed it (which is why I decided to clean it up, document it, and release it). I’m really glad some people are taking the time to read through the docs I prepared (spent more time on those than the code! No joke.)
I’ve been meaning to put together a screencast for the site to really draw some attention to the whole idea of Template, and some of the added features like cascading views, add_js and _css, using multiple template configs, etc.
My words are sincere, you really deserve them since you’ve done a great job
Colin Williams - 05 August 2008 07:39 AM
I’m really glad some people are taking the time to read through the docs I prepared (spent more time on those than the code! No joke.)
I always start reading the docs, when they’re available and worth reading.
Template’s User guide adheres to CI guidelines and the result is clean and very useful.
I believe you’ve spent more time on docs than coding the library, that’s why most of the contributions come with scarse-to-no documentation.
Even in this field CI has pointed all of us in the right direction,; it’s up to us to follow the CI way…
I believe you’ve spent more time on docs than coding the library, that’s why most of the contributions come with scarse-to-no documentation.
I touched on this a bit in the Template 1.1 thread, but documentation is really a key part of the iterative process. When you sit down and focus on explaining your API, certain things come to light. Things you thought were clear on their own aren’t so clear. Shortcuts you took suddenly appear bad when supported by a list of caveats. New features expose themselves.
I would encourage all CI contributors to start on their documentation from the start—for them as producers as equally for us as consumers and users.
A quick question: how did you make the documentation? It’s very much alike to the CI docs. Did you just recreate it, or is there some sort of cms/wiki behind it? Cuz I’m writing a library myself and thinking of publishing it. If/When I publish it, I’d love to create a similar documentation!
They give out the CSS needed to style it accordingly, so I started with that and obviously made some mods along the way. There is no CMS/wiki to drive it (sadly…). It’s just plain-old, hand-coded HTML files.
Also, I just found out that’s it’s SUPER easy to add <script> tags in the <head> element so you can easily add little bits of javascript where you need them, but leave them out where you don’t…
All it needed for me was a better written template file.
For advanced CSS, JavaScript, and other asset management, look into the AssetLibPro library. Also, Ocular is a library very similar to my Template (predates my Library by far, shame about the name though) that has some of the advanced asset inclusion features found in AssetLibPro.