Welcome Guest, Not a member yet? Register   Sign In
Updating config/routes.php using mysql
#8

[eluser]mattnewark[/eluser]
Hi, Me Again Smile

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.



Messages In This Thread
Updating config/routes.php using mysql - by El Forum - 07-14-2014, 04:44 AM
Updating config/routes.php using mysql - by El Forum - 07-14-2014, 09:03 AM
Updating config/routes.php using mysql - by El Forum - 07-14-2014, 09:55 AM
Updating config/routes.php using mysql - by El Forum - 07-14-2014, 12:14 PM
Updating config/routes.php using mysql - by El Forum - 07-14-2014, 12:27 PM
Updating config/routes.php using mysql - by El Forum - 07-14-2014, 12:51 PM
Updating config/routes.php using mysql - by El Forum - 07-14-2014, 12:53 PM
Updating config/routes.php using mysql - by El Forum - 08-20-2014, 01:51 PM
Updating config/routes.php using mysql - by El Forum - 08-20-2014, 03:12 PM
Updating config/routes.php using mysql - by El Forum - 08-21-2014, 01:46 AM
Updating config/routes.php using mysql - by El Forum - 08-21-2014, 07:34 AM
Updating config/routes.php using mysql - by El Forum - 08-21-2014, 08:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB