Welcome Guest, Not a member yet? Register   Sign In
Need a template library like master page ASP.NET or Zend Framework
#1

[eluser]greedyman[/eluser]
Have any template library like this? I have just set up a modular library, it's seem very interesting. And now, I want to find a template library can help me manage multi template. I'm using newest version of CI.

Normally, I will split header and footer. Then, include them into the page (only have contents) I want and in the method I call it by $this->load->view('page', $data);
#2

[eluser]Pert[/eluser]
application/views/header.php
Code:
Header stuff

application/views/content.php
Code:
<? $this->load->view('header') ?>
<p>body content
#3

[eluser]greedyman[/eluser]
[quote author="Pert" date="1371034469"]application/views/header.php
Code:
Header stuff

application/views/content.php
Code:
&lt;? $this->load->view('header') ?&gt;
<p>body content
[/quote]

Ok, I see. But I wanna other way better than I said.
#4

[eluser]anis2505[/eluser]
Code:
&lt;?php
//Class MY_Controller
class MY_Controller extends CI_Controller{
static $layout="default";
public function parse($view, $data = null){
        $data['view'] = $view;
        $this->load->view(static::$layout.'/header',$data);
        $this->load->view(static::$layout.'/container',$data);
        $this->load->view(static::$layout.'/footer',$data);
    }
}
?&gt;

//Template views/layout/header.php
&lt;?php
//Some code here
?&gt;

//Template views/layout/footer.php
&lt;?php
//Some code here
?&gt;

//Template views/layout/container.php
&lt;?php $this->load->view($view) ;?&gt;
#5

[eluser]greedyman[/eluser]
[quote author="anis2505" date="1371053692"]
Code:
&lt;?php
//Class MY_Controller
class MY_Controller extends CI_Controller{
static $layout="default";
public function parse($view, $data = null){
        $data['view'] = $view;
        $this->load->view(static::$layout.'/header',$data);
        $this->load->view(static::$layout.'/container',$data);
        $this->load->view(static::$layout.'/footer',$data);
    }
}
?&gt;

//Template views/layout/header.php
&lt;?php
//Some code here
?&gt;

//Template views/layout/footer.php
&lt;?php
//Some code here
?&gt;

//Template views/layout/container.php
&lt;?php $this->load->view($view) ;?&gt;
[/quote]

I found the other way to do this. I create a template folder with images, css, js and a file index.php, index.php is the master page. In this master page, beside code html I have php code: $this->load->view('page'). In the controller, with any method that I'm going to call index.php file and pass view name to it. It means that call view in view.
#6

[eluser]anis2505[/eluser]
[quote author="greedyman" date="1371057290"]
I found the other way to do this. I create a template folder with images, css, js and a file index.php, index.php is the master page. In this master page, beside code html I have php code: $this->load->view('page'). In the controller, with any method that I'm going to call index.php file and pass view name to it. It means that call view in view.[/quote]

it's all the same. I just wanted to make sure that all parts of template are as much independent as possible. Well I guess your idea is much cleaner.

But why not using other templates engines Smarty Rain or anything else.
#7

[eluser]greedyman[/eluser]
[quote author="anis2505" date="1371064422"]But why not using other templates engines Smarty Rain or anything else.[/quote]

Thanks. Your answer is the best answer.




Theme © iAndrew 2016 - Forum software by © MyBB