Welcome Guest, Not a member yet? Register   Sign In
need help with dynamic URI Routing
#1

[eluser]Dainius123[/eluser]
Hello everyone, i'm new to codeigniter[one month], and now i'm stuck againSmile,here is the problem (thanks for help!):

In my main page i have three categories:

blabla-1
blabla-2
blabla-3

site administrator is able to change names of these three categories[i changed them with URI Routing]; If site admin wouldn't change names i could just write:
Code:
$route['blabla-1']="first_group/sort1";
$route['blabla-2']="second_goup/sort2";
$route['blabla-3']="fifth_group/sort2";
and very easilly access my controllers methods, but my admin can change names of categories, soo static URI Routing isn't helping me, because if admin will change name of blabla-1 to dladla-1 my link to "first_group/sort1" will crash.
[in my main page i can change that link[blabla-1 to dladla-1], but how to change it in routes.php? ]
I hope someone will understand my broken english and my problemSmile Thanks!

Dainius
#2

[eluser]xarazar[/eluser]
Here's an idea:

Code:
$route['^(?!admin)\S*'] = "your_default_controller/index/$1";

Use that in your route config and handle the requests through your index function in the default controller.

The 'admin' exclusion in the regular expression allows you to create a separate controller for admin.
#3

[eluser]Dainius123[/eluser]
i always know in wich controller i have to go to get what i need even after admin changes categories, my main problem is how to make their names appear in URL?Smile

i have array with all categories. So if i have a link: /group1/sort2 even after admin changes name of categorie i will go to /group1/sort2 but in my address bar i will not have changed categorie name because if i would know in what name admin will change it i could change it thru routes.php...




Theme © iAndrew 2016 - Forum software by © MyBB