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

(09-08-2015, 06:37 AM)mwhitney Wrote: 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); 

Thank you again for all your help! I am a little confused as to one part of the sample code.

In the previous post you will see all the pieces of code that make up my home page. My question is this, if I have 4 pieces of different content views to insert into the template on different pages (home page->content_home, applications page->content_applications, faq page->content_faq, howto page->content_howto).... How does 'content_View' know which piece of content I am calling for on a certain page? As well as the content inside the <title></title> would change. Any thoughts there?

Thanks again

Josh
Reply


Messages In This Thread
RE: Detailed Explanation of a Controller & Model? - by Josh1985 - 09-09-2015, 10:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB