URI for Community: www.mycommunity.net/membername |
[eluser]joytopia[/eluser]
Hello CI-friends, I am new with CI and I would like to build a community site. To get the site from a member, the website-visitor should type a URI like this: www.mycommunity.net/membername perhaps with aditional parameters: www.mycommunity.net/membername/param1/param2 My idea was to bend the error-message 404 to a certain controller, which searches in the usertable, if a user exists or not. Does this make sense and how can I do this? Any better idea? Thanks for your help! Bernd
[eluser]Jay Logan[/eluser]
Edit your routes to have (:any) point to to your member controller. Then in your member controller, do an IF check to see if the member name is valid, ELSE show 404.
[eluser]joytopia[/eluser]
Thank you, J-Slim! Seems to be simple. If I want to use some other controllers, i.e. login or sign up, do I have to define them before the (:any) point? regards, Bernd
[eluser]watonlyme[/eluser]
[quote author="joytopia" date="1252278515"]Thank you, J-Slim! Seems to be simple. If I want to use some other controllers, i.e. login or sign up, do I have to define them before the (:any) point? regards, Bernd[/quote] Yes, you have to. ![]()
[eluser]Aken[/eluser]
You can do that quickly with a single route. Code: $route['(signup|register|login|logout|help)'] = "$1";
[eluser]joytopia[/eluser]
[quote author="Aken" date="1252327407"]You can do that quickly with a single route. Code: $route['(signup|register|login|logout|help)'] = "$1"; Thanks for the smart code! I think, with this I would have to put all functions into the member-controller. Now I have done the additional functions into the controller "go". The third line is for a numeric member-code, i.e. a member wants to invite s.o. or send him points or another gift. Code: $route['go'] = "go"; Regards, Bernd
[eluser]Aken[/eluser]
"members" was just an example. You always want more specific routes to be first. So with that given example, you'd want 'go/(:any)' to come before 'go'. Also be careful with this line: Code: $route['(:any)/(:num)'] = "code/code_find/$1/$2"; If I were to go to example.com/somewhere/498272, CodeIgniter would route to a url like example.com/code/code_find/somewhere/498272. I don't think you'd want your "somewhere" location included with your code_find function (at least in the URI route).
[eluser]n0xie[/eluser]
Take a look at the _remap function. http://ellislab.com/codeigniter/user-gui...#remapping
[eluser]joytopia[/eluser]
[quote author="Aken" date="1252342892"] Code: $route['(:any)/(:num)'] = "code/code_find/$1/$2"; If I were to go to example.com/somewhere/498272, CodeIgniter would route to a url like example.com/code/code_find/somewhere/498272. [/quote] This means: example.com/membername/498272 will find the gift-code 498272, given from a certain member. Other functions, like login etc. are called by the "go"- Controller: example.com/go/login (or other predefined routings)
[eluser]Aken[/eluser]
Yes, I understand the structure behind it. But look closely at the example URLs I gave. Something tells me you don't want anything but a number in the code_find URL. |
Welcome Guest, Not a member yet? Register Sign In |