0

On my site some users have the permission to see others' profile.

I'm looking to show a view in a block containing a food content type. It will be displayed on the profile page of the users (user/*). The block will contain content associated with that user (somehow I need to tell that when I am creating the content).

For example: Content "rice" belongs to user1; content "potatoes" belong to user2.

When I enter the user1's profile I see "rice"; when I enter user2 profile I see "potatos". It's the same block with the information changing according to the user profile I am seeing.

2

What you're wanting is a contextual filter for your view. Create a node view with a block display and in the Advanced section under Contextual Filter click the Add button.

From there you can add Content: Author uid which will tell the view to filter by author UID. On the popup modal, under the WHEN THE FILTER IS NOT.... fieldset, select Provide default value with Type of Raw value from URL and Path component of 2. This essentially tells the view to pull the UID from Drupal's internal path (i.e. the XXX in /user/XXX when viewing a user page).

After saving the view, you should be able to place it your region to display against user profile pages.

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.