I have the following folder structure wherein inside the "views" folder I have several static pages organized by their "parent":
I have the following controller to serve all the views that are direct children of "pages".
I have no problems linking to the top-level views under "pages" but when I traverse to a subfolder, it returns a 404.
htaccess for reference:
route.php
What I want to achieve:
From the folder structure above, I want to show "organization.php" and "history.php" through Pages::view() and calling them in my header as:
Current workaround:
I made specific classes similar to Pages::view() for each of these subfolder views such as About::organization() and About::history().
I have no idea if I can serve subfolder static pages without resorting to the strict "controller/method" pattern but I hope you can help me with this.
Currently there are no specific questions like mine online so I am looking forward to your advise.
Code:
my_project/
application/
views/
pages/
about.php
about/
organization.php
history.phpI have the following controller to serve all the views that are direct children of "pages".
Code:
<?php
class Pages extends CI_Controller
{
function __construct()
{
parent::__construct();
}
public function view($page = 'home')
{
if(!file_exists(APPPATH.'views/pages/'.$page.'.php'))
{
show_404();
}
$data['title'] = strtoupper(str_replace(["-", "–"], ' ', $page));
$this->load->view('templates/header', $data);
$this->load->view('pages/'.$page, $data);
$this->load->view('templates/footer', $data);
}
}I have no problems linking to the top-level views under "pages" but when I traverse to a subfolder, it returns a 404.
htaccess for reference:
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /iacuc/
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /iacuc/$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /iacuc/index.php/$1 [L]
</IfModule>route.php
PHP Code:
$controller_views = 'pages/view';
$route['default_controller'] = $controller_views;
$route['404_override'] = '';
$route['translate_uri_dashes'] = TRUE;
$route['pages/(:any)'] = $controller_views.'/$1';
$route['(:any)'] = $controller_views.'/$1';
What I want to achieve:
From the folder structure above, I want to show "organization.php" and "history.php" through Pages::view() and calling them in my header as:
Code:
<a href='<?php echo base_url().'about/organization'; ?>'>Company Organzation</a>Current workaround:
I made specific classes similar to Pages::view() for each of these subfolder views such as About::organization() and About::history().
I have no idea if I can serve subfolder static pages without resorting to the strict "controller/method" pattern but I hope you can help me with this.
Currently there are no specific questions like mine online so I am looking forward to your advise.