[eluser]mattnewark[/eluser]
Hi, Me Again
The code from previous adds the info to the cache file which is great, now I am including the cache file in the routes file so that it dynamically updates the $routes.
What is happening is when I update the routes the info that is in the routes file shows at the top of the page, I have no idea why it is showing, it seems as though it is echoing the file contents.
Also, even though the routes file is updated and is in the routes.php file the routes are not working.
Model:
Code:
function cache_routes ()
{
$this->db->where('route', '1');
$query = $this->db->get('cms-page');
$route = 'site/pages/main';
$data = '';
foreach ($query->result() as $row)
{
$data =$data.'$route["' . $row->page_url . '"] = "' . $route . '";';
}
write_file(APPPATH . "cache/routes.php", $data);
}
Controller:
Code:
function update_routes()
{
$this->cms_model->cache_routes();
redirect('admin/cms', 'refresh');
}
Routes.php
Code:
require_once("application/cache/routes.php");
which produces this:
$route["about"] = "site/pages/main";$route["events"] = "site/pages/main";$route["news"] = "site/pages/main";$route["events/organise-your-event"] = "site/pages/main";$route["referrals"] = "site/pages/main";$route["fundraising"] = "site/pages/main";$route["care"] = "site/pages/main";$route["volunteering"] = "site/pages/main";$route["business"] = "site/pages/main";$route["test"] = "site/pages/main";
404 Page Not Found
The page you requested was not found.
in the view.
Can anyone please shed some light on why this happening and what I can do to to get the $routes reading form the cache file and not showing in the view.