Welcome Guest, Not a member yet? Register   Sign In
using routing on codeigniter
#1

[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 ?
#2

[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...)
#3

[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
#4

[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.
#5

[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)
#6

[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.
#7

[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..
#8

[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
#9

[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




Theme © iAndrew 2016 - Forum software by © MyBB