Ok, so here's my problem. I feel it's really very simple and I am missing something. I have a Drupal 7 view which shows a certain type of content. Say it has a url mysite.com/article. What I want is, if the url is like mysite.com/article/me, it would load the articles posted by this current user. "me" will always be "me" and would not take any id/username.

Hope the problem is clear. Thanks


I think you are missing one of the buried options.

  • Make a view, configure it the way you need.

  • Make a Page display, and set the path to article/me

  • Add a Relationship for Content: Author. This is likely not needed, unless you want to pull in author fields and display them or if you need the author name explicitly somewhere in another filter.

  • Add a Contextual Filter for Content: Author uid; it should automatically pick up the relationship. In the options for When the filter value is not available, select Provide default value. In the dropdown, choose User ID from logged in user.

I think you are missing the last part of the final step. I always forget where that one is. It helps if you configure views to always show the advanced settings (see admin/structure/views/settings).

| improve this answer | |

Well thanks MPD, your answer provided the solution. I am just re-iterating the same here in case anyone else needs

What I did was

  • create a view with two separate pages, one having the url mysite.com/articles and the other mysite.com/articles/me

  • In the "me" page I simply added a contextual filter on author:uid (didnt need the relationship as it comes by default) and gave a default value of "User ID from from logged in user" for filter not being present in the url and made that for the "me" page only.

  • As for the original without "me" page, which will also extend the contextual filter of the "me" page, we need to set the filter not being present in the url to "Display all results for the specified field" and make it "All displays (except overriden)".

Bingo!!! your view is ready now. Hope I explained myself clearly, and thanks again to MPD.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.