Upgrade Your Drupal Skills
We trained 1,000+ Drupal Developers over the last decade.
See Advanced Courses NAH, I know EnoughUse Views to Show Content Created by Drupal Users
One OSTraining member wanted to allow site admins to show the content created by different users.
For example, the admins wanted to see all the articles written by a particular user, or all the orders they made in the store.
I'm going to make this happen by creating a search page using Views.
First, make sure that users are associated with your content, as in the example below:
- Go to Structure > Views > Create new view.
- Choose to Show "Content".
- The other settings you can choose according to your needs.
- Under the "Advanced" tab on the right-hand side, click "Add" next to "Relationships":
- Search for and choose the "Content: Author" relationship.
- Click "Apply (All displays)" twice to save the relationship.
- On the left-hand side, under Filter Criteria, click "Add".
- Search for and choose "User: Name (raw)".
- Click "Apply (All displays)".
- Check the box, "Expose this filter to visitors, to allow them to change it".
- Click "Apply (All displays)".
- Save your view.
- Visit the view on the front of your site, and you should be able to search for users' content, using the exposed filter:
Pro tip: inside the View, set "Use Ajax" to "Yes" under the "Advanced" tab on the right-hand side. This will allow the search to load without refreshing the whole page.
About Drupal Sun
Drupal Sun is an Evolving Web project. It allows you to:
- Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
- Facet based on tags, author, or feed
- Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
- View the entire article text inline, or in the context of the site where it was created
See the blog post at Evolving Web