I've made a view to display content to only the person who created it by using the argument UID from the logged in user. This works because it only displays content that person has made, but i want the admin to see all of the content from the view.

I tried adding another argument using user:name 'admin' but the query became UID and user:name.

How do i get the view to display content to only the person who created but display all of the content for the admin?

Thanks

Comments

mcfilms’s picture

I would think the simplest method would be to clone that view and remove the argument. Then just display both views on the same block or page, but make one exclude the Admin and the other only visible by the admin.

A list of some of the Drupal sites I have designed and/or developed can be viewed at motioncity.com

Corbula’s picture

How do i get one view to display for admin and the other view to display for users?

Corbula’s picture

i tried changing the access control for the view to a role that is only assigned to the admin on one view, and on the other i set it to authenticated user. But this didn't work.

How do i get one view to show for users and another view on the same page to show for the admin?

mcfilms’s picture

"Didn't work" doesn't give much to go on. But you probably logged in and got two views in the block. (I'm assuming it's a block view.) That's because the Admin role IS an authenticated user. You'd want to grant one view to Anonymous users and one to Authenticated users.

Also, by the way, if it IS a block view, you can set the visibility of the block in the theme's block configuration section.

A list of some of the Drupal sites I have designed and/or developed can be viewed at motioncity.com

Corbula’s picture

It's actually a page view with a table style.

If i set one view to anonymous access then my (authenticated) users can't see the view.

What i meant by it didn't work is, for my (authenticated) users it's showing just their nodes in a table, which is right. However, it's still showing only the nodes the admin has created to me (the admin). I want (me the admin) to be able to see all of the nodes created by everyone not just my own.

liberatr’s picture

Panels with a context could do this very easily. Create two variants with selection rules - one is for a certain user role, the other is for admin. If you put the admin one "above" the other, then it takes effect before the one lower on the list, so the authenticated user thing is a fall back.

You could also use a function like hook_views_query_alter() to rewrite the argument if the current user has some permission.

Ryan Price
Blink ReactionDrupalEasy Podcast