• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling multiple header/footer template and setting in route

#1
Hello everyone
I am new to codeigniter and want to use it for a fairly large project. I intend to use two different bootstrap template.
The first one is working but I don't understand why the second is'nt.
below is the controller code
PHP Code:
?php
    class Pages 
extends CI_Controller{
 
     public function view($page 'home'){
 
       if(!file_exists(APPPATH.'views/pages/'.$page.'.php')){
 
         show_404();
 
       }
 
       $data['title'] = ucfirst($page);
 
       $this->load->view('templates/header');
 
       $this->load->view('pages/'.$page$data);
 
       $this->load->view('templates/footer');
 
     }

 
     public function iview($page 'volunteers'){
 
       if(!file_exists(APPPATH.'views/ipages/'.$page.'.php')){
 
         show_404();
 
       }
 
       $data['title'] = ucfirst($page);
 
       $this->load->view('templates/iheader');
 
       $this->load->view('ipages/'.$page$data);
 
       $this->load->view('templates/ifooter');
 
     }
 
   }
 
?>
Below is the change I made in the application/config/routes.php

Quote:$route['default_controller'] = 'pages/view';
$route['(:any)'] = 'pages/view/$1';
$route['ipages/(:any)'] = 'ipages/iview/$1';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
Reply

#2
@ chized
Are you receiving any error messages?
Reply

#3
In your second function. The if condition. Should it be checking for 'iviews/ipages/' instead of 'views/ipages/'? There seems to be a discrepancy between the function and the routes.
Reply

#4
Try change it:


Quote:$route['ipages/(:any)'] = 'ipages/iview/$1';


to it:


Quote:$route['ipages/(:any)'] = 'pages/iview/$1';


https://codeigniter.com/userguide3/gener...l#examples
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.