A
A
Alexander M2016-02-23 18:37:25
CodeIgniter
Alexander M, 2016-02-23 18:37:25

Is it possible to make different categories in the same URI segment, routing in Codeigniter?

Hello everyone, closer to the middle of the project implementation, I ran into a problem with routing restrictions.
The site of car dealerships of the Russian Federation for example.
This url leads to the company's page
/russia/moskva/avtosalon-na-porspekte-12
And this one leads to the page of all companies in Moscow
/russia/moskva
I got to the functionality of splitting by car brands, I wanted
/russia/moskva/toyota
to display all Toyota salons in Moscow.
Well, I think you already understood what problem I faced.
in routes.php

$route['russia/(:any)'] = 'city/view';
$route['russia/(:any)/(:any)'] = 'firm/view';

in fact, this is how the list of companies in the city and the company card rulitsya.
I'm still out of the situation. I made a breakdown by brands like this
/ russia / moskva / avto / toyota
, respectively, in routes.php . I
$route['russia/(:any)/avto/(:any)'] = 'mark/view';
spent a lot of time googling, but there was no solution yet.
Who faced and decided / did not decide, please share your advice.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
evnuh, 2016-02-25
@alexander7779

And what's the problem? Imagine that you are a computer, how would you yourself understand that avtosalon-na-porspekte-12 is a company, and toyota is a car brand?
I think not, so they need to be separated somehow, for example, companies start with /russia/moskva/avtosalon-
and cars with
/russia/moskva/car-
Then the computer will be able to identify. Or hardcode all brands of cars directly into the regexp.
And it's not good to interfere with English and the letter in yurl.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question