简体   繁体   中英

CodeIgniter template with other modules ( HMVC? )

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM