Welcome Guest, Not a member yet? Register   Sign In
Username for Controller
#1

[eluser]Unknown[/eluser]
Hello,

I'm trying to figure out how some sites display a username for their profile page (e.g. http://www.foobar.com/johndoe). Would you just define a controller and all the actions for the profile and simply when a new user is added their username become a controller that extends your profile controller?

I'm sure it's a simple question, but it perplexes me at the moment.

Thanks,
Ben
#2

[eluser]techgnome[/eluser]
I'd probably set it up so that the urls look like this:

/users/profile/username ... users is the controller, profile the method and the user name becomes the parameter passed to it.

but that's how I'd do it - mostly for simplicity... Another option would be to set it up like that, then maybe manipulate the htaccess so that when there is only one segment, it routes to the users/profile controller/method... *shrug*

-tg
#3

[eluser]frist44[/eluser]
[quote author="bbabics" date="1287592782"]Hello,

I'm trying to figure out how some sites display a username for their profile page (e.g. http://www.foobar.com/johndoe). Would you just define a controller and all the actions for the profile and simply when a new user is added their username become a controller that extends your profile controller?

I'm sure it's a simple question, but it perplexes me at the moment.

Thanks,
Ben[/quote]

I generally break out profile into a separate controller. And I'm not sure how you're handling login, but I generally stuff some user info into a session variable. One piece of info is the userid, which just comes from ID of that particular user from the users table. since I have that in session, I go to www.domain.com/profile and the index function of the profile controller sucks the userid out of the session variable. This way, you don't have to start putting usernames in the URL and all that.




Theme © iAndrew 2016 - Forum software by © MyBB