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

Hello, As I am a beginer with CI, I am having a issue by defining sub pages which are in the sub folders.

What I want :
  • Directory should be like : application/views/pages/hosting/hosting-about.php
I am successfully done working with : application/views/pages/aboutme.php

My Pages controller :
Code:
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('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');
     //
     // }

   }

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


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


$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;


With this configuration I can access : http://localhost/mysite/contact/
But I want to access like this : http://localhost/mysite/hosting/hosting-about.php

There is no internal relation between pages like parent or child, I just want to access through the sub folder within the pages folder.

As I am new with CI, please help me with the broad explanation and from best practice perspectives. 
Thanks in Advance !
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