1

Hy all,

I'm interested in your opinion about this topic because I don't know anything about it, but i want to do it right.

First things first. I know how PHP MVC works and played with it in CodeIgniter. That's why I prefer CodeIgniter. But I'm open for other frameworks.

I like to create some kind of CMS ( mostly to learn and experiment with ) in an framework. I've played with OpenCart in the past and I like that template system. It's got an template folder with separate things like common, checkout, module and so on.

The only thing that you have to do to render it all is the following:

$this->template = 'default/template/newsletter/newsletter.tpl';
        $this->children = array(
            'common/header',    
            'common/content_top',
            'common/column_left',
            'common/column_right',
            'common/content_bottom',
            'common/footer'
        );

        $this->response->setOutput($this->render());

In CodeIgniter, that would look something like this:

    $this->load->view('templates/header', $data);
    $this->load->view('templates/content_top', $data);
    $this->load->view('templates/content_left', $data);
    $this->load->view('pages/'.$page, $data);
    $this->load->view('templates/content_right', $data);
    $this->load->view('templates/content_bottom', $data);
    $this->load->view('templates/footer', $data);

So what I basically want is that you've got all these separate files ( header, column left, right or whatever ), and that they automatically ( like some kind of magic ) are loaded in the right place in the main template, with the right data ( the data is coming from an controller / model ).

I've read that HMVC is the right way to do this. This "extension / library" for CodeIgniter is coming back everywhere I search about this topic: codeigniter-modular-extensions-hmvc.

Also did I read something about smarty

Is using that HMVC extension or smarty the right way or should I use an whole other framework? What's your view about this?

Thank you very much in advantage

UPDATE

After some googling, Laravel also came up. It's got Blade as template engine. What do you guys think about that?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Mathlight
  • 6,436
  • 17
  • 62
  • 107
  • you can read more about HMVC here http://stackoverflow.com/questions/5454337/mvc-vs-hmvc-for-web-application-development – Nassim May 19 '15 at 21:16

1 Answers1

2

i will suggest you not to use any template engine if you have big project and you have to many visitors because. template engines compile pages and creates a cache file of pages later you will notice that you have cache files size more than you actual project, i have used dwoo template engine but lots of cache files and problem was we can not disable cache in dwoo which i was deleting manually, but later i found really nice template parser which pyrocms is also using name lex, you can use this with phil's template library can solve your template partials problems.

here is phil's template library link Template library

and here is lex template parser link Lex Template parser

umefarooq
  • 4,540
  • 1
  • 29
  • 38
  • Thank you for your answer. But what's the benefit for not using an engine, but using an library / parser? ( what's the difrnce? ) – Mathlight Sep 01 '13 at 11:30
  • check the lex parser documentation, you can use template engine like tags, if you want to go with plane php then use only themplate library which also has feature of viewing template partials – umefarooq Sep 01 '13 at 13:14