Welcome Guest, Not a member yet? Register   Sign In
how to rewrite/remap/route ?
#1

[eluser]ka-spot[/eluser]
I'm building CMS and I have different controllers for Users, Pages, Products, Categories, etc.

Database table with urls for products and pages.

And I want this:

example.com/some-page -> check db table -> execute controller pages
example.com/some-product -> check db table -> execute controller products
example.com/login -> check db table -> execute controller login
example.com/вход -> check db table -> execute controller login
example.com/register -> check db table -> execute login/register
and so on..


How to do it ?
#2

[eluser]Phil Sturgeon[/eluser]
Use $route['404_override'] and send it to a "pages" controller, which has a public function _remap();

Inside that remap put your database logic and find a page, or output a 404 page.
#3

[eluser]ka-spot[/eluser]
[quote author="Phil Sturgeon" date="1340543908"]Use $route['404_override'] and send it to a "pages" controller, which has a public function _remap();

Inside that remap put your database logic and find a page, or output a 404 page.[/quote]


I still dont understand how to execute login/register (users controller with his own methods) from "pages" controller (different controller)?
#4

[eluser]Phil Sturgeon[/eluser]
You are looking at it the wrong way. You are thinking:

1. Send everything to pages except...
2. Send only users login and logout to their method

Wrong.

1. Send specific custom routes as normal.
2. Allow CI to route controllers and methods as it always does
3. Use the 404_override to send everything else to the pages controller.
#5

[eluser]ka-spot[/eluser]
Get it.




Theme © iAndrew 2016 - Forum software by © MyBB