problem with Query database in routes.php file |
[eluser]widiastono[/eluser]
dear all, I have problem to query database table in routes.php file, this the details story: I have table in database which contains some filed mic_modules id name active i want to query which modules name is actice and use it to route to my url, sample, if i get query news is active from my mic_modules tables so i can redirect to http://127.0.0.1/ci/index.php/news, but if i can't it when i access http://127.0.0.1/ci/index.php/news i will route to http://127.0.0.1/ci/index.php/default. Simple explaination is i want to get which modules is active but i query it from database table. any advice for this problem? please help... widiastono
[eluser]esra[/eluser]
What about adding a uri column to your modules table? Then handle the condition in your controller using an if/else statement that considers the query results. You can use the redirect() function in url helper to handle the routing.
[eluser]widiastono[/eluser]
that's bring me to what not i want to... if i write url --> http:\\127.0.0.1\ci\index.php\xxx but xxx can't find at controller directory so 404 error page will show, in this case i want this will be redirect to default controller. if i use route like this $route['(.*)'] = 'default/$1'; it will wrap all uri and redirect to http:\\127.0.0.1\ci\index.php\default
[eluser]widiastono[/eluser]
FIY, i have been try use hooks too but i can't load database at pre_system hooks, any suggestion ??? |
Welcome Guest, Not a member yet? Register Sign In |