Welcome Guest, Not a member yet? Register   Sign In
Detailed Explanation of a Controller & Model?
#6

The easiest way to setup a single-page template and load a view into that template is to echo a variable in the template and set that variable to the result of loading the view (making sure to pass true as the third parameter of $this->load->view() so it will return the data instead of staging it for output).

For example, using a template view:
PHP Code:
<!DOCTYPE html>
<
html>
<
head>
    <
title>Example</title>
</
head>
<
body>
    <
div class='content'>
        <?
php echo $contentView?>
    </div>
</body>
</html> 

Then the controller would do something like this:
PHP Code:
$data['contentView'] = $this->load->view('contentView'$contentDatatrue);
$this->load->view('template'$data); 
Reply


Messages In This Thread
RE: Detailed Explanation of a Controller & Model? - by mwhitney - 09-08-2015, 06:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB