Attaching users id to my url structure |
[eluser]RalphLeMouf[/eluser]
I am having great trouble figuring out how to attach the users id to the url when on their profile. I have read up on uri segments and routes but still can't figure out how to make it work. Too much code to post on here, but go HERE for a link to all the code.
[eluser]zykapratama[/eluser]
I use the session id and send it to capture any action in which I will click example : Code: <?php echo form_hidden('IDUser', $this->uri->segment(4)); ?> and then I call on the controller Code: $id = $_POST[IDUser];
[eluser]RalphLeMouf[/eluser]
That is good to know for future reference but that does not really apply to what I am trying to do. I'm not trying to make a link right now, I'm just trying to put that in the controller and make it dynamic per $userid and then my system well be able to tell if it's a user looking at their own profile or looking at someone elses. Make sense?
[eluser]CroNiX[/eluser]
You didn't provide enough info to adequately answer. You should post your whole controller. Your route doesn't look good at all from what I can tell. Whatever appears as the 2nd segment in the request, after "profile" will be sent to a CONTROLLER of the same name of that 2nd segment. I don't think that's what you're intending. If the request was http://yoursite.com/profile/account/24 Your route is saying "send "id_24" as the first parameter to the account controller", so there must be a controller named "account" for that to work. I think you have an account method in your profile controller but hard to know with only one method provided. If what I said is true, then your route should be: Code: $route['profile/([a-z]+)/(\d+)'] = "profile/$1/id_$2";
[eluser]RalphLeMouf[/eluser]
I actually tried that route. Didn't work either
[eluser]RalphLeMouf[/eluser]
I've gone ahead and implemented the mod rewrite and gotten rid of "index.php/" in my url, however I'm still having the original issues. I am able to get the proper url string but it won't load the page. For example I'm getting "Unable to load www.mysite.com/account/profile/218" I've been really stuck on this for a week now and any help or answers or direction are greatly appreciated and needed.
[eluser]InsiteFX[/eluser]
Code: // wrong
[eluser]RalphLeMouf[/eluser]
Good catch. I'm still having the same problem, however
[eluser]CroNiX[/eluser]
why don't you create a simple controller just to test with and then once you get it working add your real stuff. Code: class Test extends CI_Controller { Then go to http://yoursite.com/test //should say 'index hit' http://yoursite.com/test/view //should say 'view hit' and bool(FALSE) since no ID was supplied in the 3rd segment http://yoursite.com/test/view/234234 //should say 'view hit' and your id 234234 You don't really need a route for this, but you should validate $id. |
Welcome Guest, Not a member yet? Register Sign In |