Sunday, January 27, 2008

smarty or CI templating

As I am very new to both smarty and template class of CI, so I found both interesting, as smarty is full fledged template engine, it must full fill the transparency between the designer and the programmer, but in terms of the CI template class, its very easy to use as I am very friendly to CI, so found not bit easy to use it. User guide provides full help to use the template class.

I tried to make the job of designer a bit easier so have a look.

As we know we can load model in the Controller, so we can also call the model in the View class too, so starting from the main template we will move to the controller, I know it’s a wrong approach and it disturbs the flow schema, but later we will move as per the flow too.

This is how the template will look like:

{header}

{left_panel}{center_content}{right_panel}

{footer}

now, what is required from the controller

$result[‘left_panel’]=$this->MyModel->func_name();

rather than calling the load view function use:

$this->parser->parse('blog_template', $result); to provide data to the view file, blog_template is the blog_template.php file.

Only drawback according to me in template parsing class of the CI Is that it won’t accept .tpl or any other extention. But smarty will help.

What will model do:

Model will use data loaded from the database and load it into the view file. Seems very confused I will soon add some controller, model and view file in order to explain it more easily.

No comments: