Welcome Guest, Not a member yet? Register   Sign In
cleanest way to implement the main layout
#3

[eluser]sirfilip[/eluser]
Here is my approach. I add render function into MY_Controller.

public $layout = 'layouts/default'; // normally you should put this into the constructor.

function render($view, $data)
{
$data['content'] = $view;
$this->load->view($this->layout, $data);
}

and i use it like this
$this->render('posts/show', array('posts' => $posts));

And the layout file looks like this
<html>
<head>
<title>Title</title>
</head>
<body>
<?php $this->load->view($content); ?>
</body>
</html>


Messages In This Thread
cleanest way to implement the main layout - by El Forum - 04-06-2011, 02:50 PM
cleanest way to implement the main layout - by El Forum - 04-06-2011, 03:47 PM
cleanest way to implement the main layout - by El Forum - 04-06-2011, 05:29 PM
cleanest way to implement the main layout - by El Forum - 04-14-2011, 03:51 PM
cleanest way to implement the main layout - by El Forum - 04-14-2011, 10:35 PM
cleanest way to implement the main layout - by El Forum - 04-14-2011, 11:48 PM
cleanest way to implement the main layout - by El Forum - 04-15-2011, 09:20 AM
cleanest way to implement the main layout - by El Forum - 04-15-2011, 01:15 PM
cleanest way to implement the main layout - by El Forum - 04-15-2011, 05:14 PM
cleanest way to implement the main layout - by El Forum - 04-15-2011, 05:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB