Not 100% sure this is possible but was requested by a colleague to make his life easier.
We have an archive of our newsletters that are sent out and the site is in a CodeIgniter framework with a couple of controllers for the different newsletters. The controller is set up as follows:
<?php
class Software1 extends CI_Controller {
public function index($software1 = 'home') {
if (!file_exists('../application/views/software1/' . $software1)) {
// Whoops, we don't have a page for that!
show_404();
}
$this->lang->load('common/menu.php');
$this->lang->load('common/links.php');
$this->lang->load('common/footer.php');
$data['title'] = basename($software1, ".html");
$this->load->view('templates/common/header', $data);
$this->load->view('software1/' . $software1, $data);
$this->load->view('templates/common/footer', $data);
}
}
So this means that currently the views are pulled from the software1 folder. The email views are labelled December 2013.html, January 2014.html etc. This works fine but my colleague asked if it was at all possible if he could separate put all of 2013 e-mails in a 2013 folder and 2014 in a 2014 folder so it makes his life easier to sort out.
Is it possible to have the controller look in multiple folders for the views or is there any other way I can achieve this so that all of the 2013 would be in software1/2013/Month 2013.html and that 2014 would be in software1/2014/Month 2014.html
Yes I know I could create separate controllers per year but am trying to avoid this and if there is a good way to do this using so if and else then that would be great. If it is not possible then that's fine I will just tell him to upload to one folder and leave it like that but any suggestions would be welcome.
Thanks
EDIT//
Current Folder Structure:
application/
---controllers/
------archive.php
------software1.php
---views/
------Software1/
---------Archive.html
---------January 2013.html
---------Febuary 2013.html
---------March 2013.html
---------April 2013.html
---------May 2013.html
---------June 2013.html
---------July 2013.html
---------August 2013.html
---------September 2013.html
---------October 2013.html
---------November 2013.html
---------December 2013.html
---------January 2014.html
And oviously have to take into account future years as well ie 2015,16,17 etc.
The I need to be able to easily define the urls in the route file currently the outes look like:
$route['(:any)/(:any)/(:any)/(:any)'] = 'Software1/$1/$2/$3/$4';
$route['(:any)/(:any)/(:any)'] = 'Software1/$1/$2/$3';
$route['(:any)/(:any)'] = 'Software1/$1/$2';
$route['(:any)'] = 'Software1/$1';
$route['default_controller'] = 'Software1/index/home.html';
$route['Archive'] = "ArchiveSoftware1/index/Archive.html";
$route['2013/January'] = "Software1/index/January 2013.html";
$route['2013/March'] = "Software1/index/March 2013.html";
$route['2013/May'] = "Software1/index/May 2013.html";
$route['2013/July'] = "Software1/index/July 2013.html";
$route['2013/September'] = "Software1/index/September 2013.html";
$route['2013/November'] = "Software1/index/November 2013.html";
$route['2014/January'] = "Software1/index/January 2014.html";
As it appears my question is about as clear as mud lol hopefully this will help:
So I want the folder structure:
application/
---controllers/
------archive.php
------software1.php
---views/
------Software1/
---------Archive.html
------------2013/
---------------January 2013.html
---------------Febuary 2013.html
---------------March 2013.html
---------------April 2013.html
---------------May 2013.html
---------------June 2013.html
---------------July 2013.html
---------------August 2013.html
---------------September 2013.html
---------------October 2013.html
---------------November 2013.html
---------------December 2013.html
------------2014/
---------------January 2014.html
Each 1 of those views is an individual webpage online the only common things they have is they are sharing the header and footer files. What I am trying to do it have 1 controller that goes if goes to url.net/2014/January will display the info in the January 2014.html view file (as I have said I have this working if the subfolders 2013 and 2014 are not there ie everything in the software1 folder and I can have this working if I use multiple controllers ie 1 for 2013 and 1 for 2014 etc. however I am trying to have it so I can do this in 1 controller that so it will look at any of the subfolders to find the correct file to display as defined by the route file.
As I said I have no idea if this is actually do able but hopefully someone can understand what I am trying to acheive and give me some way of doing this :)