CodeIgniter Forums
using routing on codeigniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forum-22.html)
+--- Thread: using routing on codeigniter (/thread-30443.html)



using routing on codeigniter - El Forum - 05-14-2010

[eluser]gordon Stewart[/eluser]
hello, I am trying to adjust

/application/config/routes.php so I can have flexible URL's

what I'm after, is to have a URL of

http://domain.com/maps/
http://domain.com/maps/region_name_1
http://domain.com/maps/region_name_2 etc...


I have

application/controllers/maps.php

and

application/models/maps_model.php


routes.php >> i have this line :-


$route['maps/(:any)'] = "maps/maps_model/$1";



is that above correct ?


when I put in my url maps/region_name or maps/region I get a 404 error

EDIT:-

from my logs, I see :-

ERROR - 2010-05-15 03:41:40 --> 404 Page Not Found --> maps/maps_model

is maps_model in a subdirectory of my controllers directory ????

or should it be in my 'models' directory ?


using routing on codeigniter - El Forum - 05-14-2010

[eluser]gordon Stewart[/eluser]
PS I've tried

/maps/?area=north
/maps/north
/maps?area=north

Nothing works -

404 Page Not Found
The page you requested was not found.

Hopefully someone can advise some solution / working examples...

Thank you

I have 'debug' ON - to '4'..

Is there a way I can tell Ci to advise the FULL / complete path name of the file its trying to find, & why its trying to find it ?


(or why its ignoring the route command...)


using routing on codeigniter - El Forum - 05-15-2010

[eluser]Shay Falador[/eluser]
For some reason you did:
$route[‘maps/(:any)’] = “maps/maps_model/$1”;
I can't see why did you call maps_model.

If you have maps controller, and say the method region_by_name you should do that:
$route[‘maps/(:any)’] = “maps/region_by_name/$1”;

Good luck


using routing on codeigniter - El Forum - 05-15-2010

[eluser]gordon Stewart[/eluser]
the model loads up a *.txt file (plain text data), & extracts information based on information passed from the main controller.

(it then (or should) pass an array back to the controller).

However, as 'nothing' works - I can't tell which part of any php script (controller or model) is at fault & fix it.


using routing on codeigniter - El Forum - 05-15-2010

[eluser]gordon Stewart[/eluser]
the model DOES exist, so i'm confused as to what file / model itr is trying to load up.

(any way to go "super" de-bug, & find out the full path of the missing file (it is trying to load)


using routing on codeigniter - El Forum - 05-15-2010

[eluser]Shay Falador[/eluser]
You get something wrong.
Models has nothing to do with routing.
Requests are going to the controller's class methods (functions of a class), through the routing system.
The models has nothing to do with the request it self, but with the controller.


using routing on codeigniter - El Forum - 05-17-2010

[eluser]gordon Stewart[/eluser]
Please can someone give a tutorial / Example of this :- (not MP3 / Video / sound)

I've tried :-

(no extra line in routes.php)

http://SERVER_NAME/maps?area=north
http://SERVER_NAME/maps/?area=north
http://SERVER_NAME/maps/north

All produce a 404 error...

added :-
$route['maps/(:any)'] = "maps/model_maps/$1";

( model_maps.php is a 'model' in the model sub directory )

http://SERVER_NAME/maps/north
http://SERVER_NAME/maps?north
http://SERVER_NAME/maps?area=north


All produce 404 error.


If I put :-

http://SERVER_NAME/maps/

the maps.php loads up correctly...

How do I pass the extra value "north" / "south" / "upper_north" / "Christmas tree" / "Whatever i want"

As a value - Function / Model / whatever. - or directly into maps.php

Thank you..


using routing on codeigniter - El Forum - 05-17-2010

[eluser]gordon Stewart[/eluser]
added this to autoload :-

$autoload['library'] = array('uri');

get error :-


A PHP Error was encountered

Severity: Notice

Message: Undefined index: core

Filename: libraries/Loader.php

Line Number: 976


using routing on codeigniter - El Forum - 05-17-2010

[eluser]gordon Stewart[/eluser]
PHEW!!!

Finally got it fixed, Lots of tiny issues, Not sure which one issue was the cause...

Though it now works as expected