Welcome Guest, Not a member yet? Register   Sign In
A better way to handle views?
#1

[eluser]JREAM[/eluser]
I was trying to think of a good way to handle views,

So if I want a create form to appear in the users/create I pop it in like below, but you can imagine this would get fairly bloated!

Code:
public function index()
{        
    /** Load the View */
    $this->load->view('header', $this->data);
    $this->load->view('users', $this->data);
    $this->load->view('footer', $this->data);
}
    
public function create()
{
    $this->load->view('header', $this->data);
    $this->load->view('users', $this->data);
    $this->load->view('users_create', $this->data);
    $this->load->view('footer', $this->data);
$this->data contains things for content, <title>, etc so its needed in all of them.


Previously In Smarty and PHP I had it this way:
Code:
if ($_REQUEST['create']) {
    $smarty->assign('create', true);
}
TPL Code:
Code:
{if $create == true}{include file=user_create.tpl}{/if}

Maybe I can do it similarly with passing the $data variable, but I'd like to see if there is a smarter way to do this Smile
#2

[eluser]flaky[/eluser]
why don't you use template library
http://www.williamsconcepts.com/ci/codei.../template/
#3

[eluser]JREAM[/eluser]
Thank you! I am new to all this an this will be great




Theme © iAndrew 2016 - Forum software by © MyBB