Welcome Guest, Not a member yet? Register   Sign In
To customize the school's url
#1

[eluser]Lokut Da[/eluser]
Hi!

First, excuse my english :-P

Well, I need to customize the url depending of school's name, and i must load the information from that school. For example:

http://www.domain.com/aa_college/ -> (school's index)
http://www.domain.com/aa_college/galery -> (school's images)
http://www.domain.com/aa_college/events -> (school's events)
http://www.domain.com/aa_college/articles -> (school's articles)

Other school:

http://www.domain.com/bb_college/ -> (school's index)
http://www.domain.com/bb_college/galery -> (school's images)
http://www.domain.com/bb_college/events -> (school's events)
http://www.domain.com/bb_college/articles -> (school's articles)

And other school:

http://www.domain.com/cc_college/ -> (school's index)
http://www.domain.com/cc_college/galery -> (school's images)
http://www.domain.com/cc_college/events -> (school's events)
http://www.domain.com/cc_college/articles -> (school's articles)

I don't have idea, how i can to do it. Htacces maybe?

Thanks in advance.

Regards.
#2

[eluser]InsiteFX[/eluser]
See the CodeIgniter User Guide Routes and _remap

InsiteFX
#3

[eluser]Lokut Da[/eluser]
Thanks for ur answer InsiteFX.

I typed on the routes file:

$route['aa_college'] = 'college/index/1';
$route['bb_college'] = 'college/index/2';

And it work ok.

But, i could to have a lot of sections and i can't to write each combination possible. This way, i will have to write on the routes.php file:

$route['aa_college'] = 'college/index/1';
$route['aa_college/galery'] = 'galery/index/1';
$route['aa_college/events'] = 'events/index/1';
$route['aa_college/videos'] = 'videos/index/1';
$route['aa_college/articles'] = 'articles/index/1';

For other school:

$route['bb_college'] = 'college/index/2';
$route['bb_college/galery'] = 'galery/index/2';
$route['bb_college/events'] = 'events/index/2';
$route['bb_college/videos'] = 'videos/index/2';
$route['bb_college/articles'] = 'articles/index/2';

Exists other way to do it?

Thanks again.
#4

[eluser]WanWizard[/eluser]
Can't you use the collage name, instead of the number? That would make things a lot easier.

An alternative is to generate them:
Code:
$route = array();

$colleges = array('aa_college' => 1, 'bb_college' => 2);
foreach($colleges as $college => $number)
{
    $route[$college] = 'college/index/1';
    $route[$college.'/(:any)/(:any)/(:any)'] = '$2/index/'.$number;
}
#5

[eluser]wiredesignz[/eluser]
Two routes each. ie:
Code:
$route['aa_college'] = 'college/index/1';
$route['aa_college(.*)'] = '$1/index/1';
...
#6

[eluser]Lokut Da[/eluser]
Thanks WanWizard.

Understand your point...

Other thing, for check are the multiples combinations:

$route[‘bb_college’] = ‘college/index/2’;
$route[‘bb_college/galery’] = ‘galery/index/2’;
$route[‘bb_college/galery/album’] = ‘galery/album/2/13’;
$route[‘bb_college/galery/album/name_imagen_a’] = ‘galery/album/2/13/4’;
$route[‘bb_college/galery/album/name_imagen_b’] = ‘galery/album/2/13/4’;
$route[‘bb_college/galery/album/name_imagen_c’] = ‘galery/album/2/13/4’;
.
.
.
$route[‘bb_college/events’] = ‘events/index/2’;
$route[‘bb_college/events/event_title_a’] = ‘events/2’;
$route[‘bb_college/events/event_title_b’] = ‘events/15’;
.
.
.
$route[‘bb_college/videos’] = ‘videos/index/2’;
...
$route[‘bb_college/articles’] = ‘articles/index/2’;
....

The project could to have a lot combinations possibles.

Wiredesignz, thanks too Smile

I don't understand that instruction:

$1/index/1

Why u use $1?

Regards.
#7

[eluser]WanWizard[/eluser]
The route definition is a regex. So whatever matches "(.*)" will be used to replace "$1" in the route.

I think you have a serious design problem. You can't solve your "name-to-number" translation problem with routes.
It would be logical to simply call "gallery/album/bb_college/name_imagen_c", and deal with the mapping of name to number in the controller, through a model that processes the parameters and fetches the correct info.
#8

[eluser]Lokut Da[/eluser]
My apologies for the long time for my answer.

I write on the route file this way:

$route['(:any)/contact'] = 'contact/index';
$route['(:any)/contact/send'] = 'contact/send';
$route['(:any)/gallery'] = 'gallery/index';
$route['(:any)/gallery/album/(:num)'] = 'gallery/album/$2';
$route['(:any)/gallery/image/(:num)'] = 'gallery/image/$2';
$route['(:any)/articles'] = 'articles/index';

It works fine! :-)

Thanks for ur answers.

Regards.




Theme © iAndrew 2016 - Forum software by © MyBB