Welcome Guest, Not a member yet? Register   Sign In
How to call member functions within a class?
#6

May I suggest another, imo, a bit simpler and cleaner solution for you.

Instead of breaking out the view loading of the header and page, just set the footer template name in a variable.

Start by setting a default template, the regular footer used on all pages except contact us page. If the page is contact us, we just change the footer template variable to what footer we want to load.

Here is an example
PHP Code:
public function view($page "index")
{
 
 // Default footer template
 
 $footer_template 'footer';

 
 if ( ! file_exists(APPPATH.'/views/truelove_view/'.$page.'.php'))
 
 {
 
   // Something
 
 }
 
 else if ($page == "contact-us")
 
 {
 
   // Change footer template
 
   $footer_template 'contact_footer';
 
 }

 
 // Load all views
 
 $this->load->view('truelove_view/templates/header');
 
 $this->load->view('truelove_view/'.$page);    
  $this
->load->view('truelove_view/templates/'.$footer_template);


Also, just a small note, you don't need to include .php file ending.
Reply


Messages In This Thread
RE: How to call member functions within a class? - by silentium - 03-17-2015, 07:29 PM



Theme © iAndrew 2016 - Forum software by © MyBB