I have a view I made that takes the user's name as an argument.

[root]/buttons-author/nicholas

Can I use the me alias module to redirect [root]/buttons-author/me to the appropriate alias? If so how? I have attempted to add the link to the menu, but it won't let me 'cause it is not valid.

I also tried just browsing to the url and it doesn't work. Perhaps this may be a feature request?

CommentFileSizeAuthor
#5 me-views-username-argument.patch8.62 KBcdale

Comments

cdale’s picture

Hi Nicholas,

I currently haven't coded up a me handler for "User:Name" but there is however one for "User:uid". If you're running views 2.3, you should actually be able to achieve what you want already using this. Here's how:

  1. Add the User:UID argument to your view.
  2. In the validator dropdown for the argument, select "User".
  3. Under "Type of user argument to allow" Select "Allow both numeric UIDs and string usernames"
  4. Make sure the "Let users enter the 'me' alias instead of their user id." option is checked. (It's down the bottom).

That should be all there is too it. This will allow users to enter their uid, name, or 'me' to get their list. I'm not sure what will happen if a users name is 'me', but I feel that is outside of the scope of the me module. Just be warned that I have no idea what will happen.

nicholas.alipaz’s picture

Thanks for the reply, but that won't work for what I am doing. It requires that I select the type as User. I want a node type. And to use a username as an argument.

I appreciate the try though. I will keep working on it.

nicholas.alipaz’s picture

What is strange is that things seem to work when I am building the view in the admin panel, but not when I view it on the site.

cdale’s picture

It is strange that it works in the admin panel but not on the site. To be perfectly honest, I'm not 100% sure how it could be working in the admin panel. None the less, as the views team has seen it ok to swap usernames and user id's like they have, I see no reason why I couldn't. I'll write up a handler for username and post the patch here. Hopefully I get it done before the next snapshot run so you can try it out. :)

cdale’s picture

StatusFileSize
new8.62 KB

I've just committed the attached patch which should allow you to do what you need. You will most likely need to clear your views cache before it will take effect. (I've often had trouble with the views cache, but it does catch on eventually). Unlike the UID argument handler however, the me alias in the username argument is off by default, so you will need to be sure to enable that option.

Please let me know how this goes for you, and if you encounter any problems or issues.

cdale’s picture

Status: Active » Needs review
cdale’s picture

Status: Needs review » Fixed

Oops. Meant to mark as fixed.

nicholas.alipaz’s picture

This fixed it for me. Thanks for the quick response! Great feature!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.