Add views 'me' argument redirection for uid and name argument handlers.
halver - April 2, 2009 - 19:26
| Project: | me aliases |
| Version: | 6.x-2.6 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
I am trying to do a very simple task: use the me alias on a view. I have created the view, then created a page display. Under path I typed me/trips, hoping it would give the current user's ID in the address bar when he/she visited that view. I also added it to the primary links menu. But when I click on the link it just puts ". . .me/trips" in the address bar. In other words, it did not replace the me with the user ID. I have configured the Me Aliases module by checking the box "Redirect to UID." Am I doing something wrong? Did I completely miss the point? Sorry, I'm just getting started here.

#1
The 'me' module works by allowing you to use me in a place where a user id would normally be used, it does not know how to use me in a place where a user object would not normally be. i.e. Drupal doesn't know that in 'me/trips', that the 'me' part relates to a user.
I think what you would want to do is the following:
That should be all you need to do, now any user that clicks on the "trips/me" link, will get only their trips.
Was this helpful?
#2
Thank you so much for taking the time to write all of that, especially for another module. I had sort of figured that out--though instead of using arguments I used a filter to filter it to the current user. I probably have too much time on my hands or I'm overthinking this--probably both--but my goal was to get the user name to appear in the address bar. The trips info is meant to be private and I was thinking that users might be discomfited if they could go to something generic like site.com/trips and see all their trips. They might think the info wasn't private to them after all. They might think that anybody who entered site.com/trips into the address bar would see their trips. Even though, of course, this is not the case. Since the word 'me' is also pretty generic, I don't think this solves this issue. Oh well, this is a very minor issue, I don't think I will worry about it too much.
Thanks again for your help. You can close this if you like.
#3
Alright. Cheers for the feedback. I might look into adding a feature that actually handles this so you can allow for redirection in views to the uid or name based on what kind of argument there is. Might be a bit tricky though, as I'm not sure how views and the path actually work together. Will see how I go. Won't get to look at this until next week sometime though.
#4
I actually got a chance to look at this this afternoon, and I think I've come up with something that will probably work for you. I'm about to commit the attached patch to the 2.x branch, which adds an option to both the USER:UID and USER:NAME argument handlers in views, so that when you select the 'allow me alias' option, another option will pop up asking if you want to redirect to the path with the uid, or the name depending on which handler you're using. I probably won't publish this in a release for a few weeks, but it will be available in the 2.x dev snapshot sometime in the next day or so, so you're welcome to try it out.
You can get to the latest snapshot by going to "View all releases" And it should be in there somewhere. :)
#5
Once I figured out the mechanics of installing a patch, it worked like a charm. Thanks very much for doing this.
In case anyone else is as clueless as me and wants to do the same:
1) I created a new view.
2) Under arguments I added 'User: Name' and selected 'Let users enter the 'me' alias instead of their user name' and 'Redirect to the users name when 'me' is entered as an argument.'
3) I filtered the view to User: Current.
4) I then created a new page with the path trips/%.
5) When I tried to add a menu item, Views informed me it could not handle this when % was used in the path. Fair enough. So I went to Admin>site building>menus, and added the path the path 'trips/me' manually. Now users can click here and get a list of their trips.
Cheers.
#6
Awesome. Thanks for the feedback. Do let me know if you run into any issues related to views. I'll probably get this out in a release later this month.
#7
Automatically closed -- issue fixed for 2 weeks with no activity.
#8
having the same problems like halver. I use friendlist and want to create a normal menu item for "friends" in the view. I followed the steps in #1 but it doesn't go. Everytime I go on www.domain.de/friend/me the site could not be found although www.domain.de/friend/1 is perfektly working. me is installed and user/edit/me works also!
#9
#10
mh.. I don't know why but views didn't accepted/saved the second me setting under "arguments" for several times. After clearing the cache and reaktivating the view with new settings i works like a charm how in #1 mentioned
#11
Sorry for my english.
I have the same problem, as IckZ, but clearing cache didn't fix it.
The first time, when i set me as argument, i used this path on views: kozosseg/%/kapcsolatok. I checked: kozosseg/1/kapcsolatok OK, kozosseg/username/kapcsolatok OK, kozosseg/me/kapcsolatok OK - it seems everything is OK.
I changed the path: kozosseg/kapcsolatok/%, then the kozosseg/kapcsolatok/me didn't work, however on views preview the argument me work well. kozosseg/kapcsolatok/1 and kozosseg/kapcsolatok/username - this wasn't problem.
Now I try to change back the path to the first (kozosseg/%/kapcsolatok), and now the argument me doesn't work.
So the first was in all order with an occasion, I changed anything then, I was not able to use the me argument.
I hope so understandable one, which I wrote! :)
#12
Sorry for the delay in replying.
The only thing I can think of, is that the "Let users enter the 'me' alias instead of their user id." option is not checked on the argument. If it's not that, then I honestly have no idea.
Have you had in luck in resolving the issue yourself?
#13
No problem. :) "Let users enter the 'me' alias instead of their user id." option was checked. I solved it by a redirection first, but today I checked it again. The "me" argument is worked fine now, so I think it may have been some cache cache problem.
#14
Hello,
The 6.x-2.7 recommended version have the patch #4?
Thanks :)
#15
Me now uses views argument validators. See #468886: me and flag-friends and #455654: Requesting use of 'Me' in argument "Node: User posted or commented".
#16
please post an exemple of use "me" and validator
#17
ack! now it work.
pippo/% don't work, but pippo/%/pippo work
maybe is the final "/" ?
#18
pippo/% should work. At least it does for me. I can't really say why it wouldn't work without more information.
#19
if you set a redirect from node/xxx to pippo/me, it work.
but if you set an alias, don't work.
drupal 6.13
Views 6.x-3.x-dev
me aliases 6.x-2.7
me aliases set: Redirect to uid
view set:
Arguments =UID
Action to take if argument is not present: Display all values
Validator: ME
Type of user argument to allow: Only allow numeric UIDs
AND: Redirect to the users uid when 'me' is entered as an argument.
#20
What is pippo an alias of? Typically aliases are for a specific path i.e., they point to a specific user, and always point to that same user. Me is not like a URL alias, in that it dynamically points to the currently logged in users uid.
Perhaps this is where the issue lies? Drupal should take care of handling alias redirects for you, so there shouldn't be much need to specifically place them in your views and such, and it is probably better not too, as that way you can change the alias, without having to go back and alter your views.