Welcome Guest, Not a member yet? Register   Sign In
Simple sub-directory pages
#3

I have done this by doing something like :

Code:
public function view($page = 'home'){

       if(!file_exists(APPPATH.'views/pages/'.$page.'.php')){
         show_404();
       }

       $data['title'] = ucfirst($page);

       $this->load->view('partials/header');
       $this->load->view('pages/'.$page, $data);
       $this->load->view('partials/footer');

     }

     public function subview($page = 'hosting'){

       if(!file_exists(APPPATH.'views/pages/hosting/'.$page.'.php')){
         show_404();
       }

       $data['title'] = ucfirst($page);

       $this->load->view('partials/header');
       $this->load->view('pages/hosting/'.$page, $data);
       $this->load->view('partials/footer');

     }

And route :
Code:
$route['default_controller'] = 'pages/view';


$route['(:any)'] = 'pages/view/$1';
$route['hosting/(:any)'] = 'pages/subview/$1';

But I will probably get the problem when I will have another folder inside pages/ , in that case I have set another route for that.

So, yeah your way is a better solution, 
Can you show me how I am going to manage route in your case ?

Thanks for the help.
Reply


Messages In This Thread
Simple sub-directory pages - by raydvard - 02-24-2017, 06:36 AM
RE: Simple sub-directory pages - by Wouter60 - 02-24-2017, 09:18 AM
RE: Simple sub-directory pages - by raydvard - 02-25-2017, 12:07 AM
RE: Simple sub-directory pages - by Wouter60 - 02-25-2017, 03:55 AM
RE: Simple sub-directory pages - by raydvard - 02-25-2017, 04:06 AM
RE: Simple sub-directory pages - by Wouter60 - 02-25-2017, 04:17 AM
RE: Simple sub-directory pages - by raydvard - 02-25-2017, 06:02 AM
RE: Simple sub-directory pages - by Wouter60 - 02-25-2017, 11:18 AM
RE: Simple sub-directory pages - by Diederik - 02-25-2017, 02:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB