Using Drupal views pager feature to display users

By adam
Wed, 2014-12-31 07:16
1 comments

Share with Others

From time to time we get a question that we feel would be beneficial to more than just the person asking. Yesterday, we had one of those questions.

Hi Shane,

I just bought your eBook today and have enjoyed some of your tutorials too.

I come from the WordPress side of development, but recently sunk my teeth into Drupal and I'm working hard and fast to get up to speed as quickly as I can, which is one reason I bought your eBook today.

I am working on a short-term Drupal contract now and have a question about a feature I'm trying to implement for better usability of a certain page.

The developer before me set up User Profiles of the company employees to display in a view as a page called Meet Our Team. Clicking on any of the profile links (photo images) in the view takes the user to that employee's User Profile page (so the page content comes from the content each employee enters into their "My Profile").

My Task: Provide a way to scroll through each profile user page (like a pager) so that users don't have to go back to the main Meet Our Team page to try the next link to the next profile they want to view. Once on any "Employee Bio" page they can just page to the next Bio.

I considered Flippy, but that requires a content type, and in this instance the User Profile account, while it is a type, is not specifically a content type.

Other's have asked on Drupal.org if a content type can be created for the User Profile type (to provide additional fields, that kind of thing) but the answers seem to be that it cannot be done.

How can I provide either a pager-like or slide-show feature in regard to flipping through User Profile pages? I need this feature on those pages, not in the view of the links that take users to those pages.

I'm still googling about this to find a solution, and because I'm only 10 weeks into Drupal, I thought I'd ask you for a recommendation for how I can make this work for our site.

Thanks for your time!

For those familiar with the Flippy module (check out the DDoD Episode) know that this allows you to "flip" between nodes of a selected content type without having to leave the current page you are on. But as noted above Flippy works with content types and user accounts in Drupal aren't content types.

After looking around a few modules, we came up with this solution. Note, there are probably better ways to do this, but depending on your site this might be a viable option.

The Idea

Create two views. One view will display all team members and the other view will display the individual users or team member.

The Steps

  1. Create a new view that shows "Users" instead of "Content".
  2. By default the user name filed will appear within the fields area. You can add any additional information you would like here, but make sure to add the UID (user ID) and exclude it from display. Note, this field also should be placed at the top of the list.
  3. Change the "output this field as a link" to go to something like "team/[uid]". The point is that you don't want the path to take you to the Drupal user profile page.
  4. If you want to limit the user profiles that appear in the view, we used an additional role of "employee" and just filtered the view to only show users who had this role.
  5. Create another view for the individual
  6. Add any additional fields you want to show. You can think of this page as the profile page for the user
  7. Set the path to "team/%".
  8. Under the pager set it to use mini pager and limit the results to only showing one at a time

Those are the basic steps to creating a pager that allows you to scroll through various user accounts. With views there are a ton of additional options you can play around with that will improve the functionality and display. This isn't the only way to do this task, and frankly it probably isn't the best, but assess your site and see if this trick will work for you.

If you would like I have attached the code for a view I created that follows the steps above. If you are new to views, you can check out our Drupal views intro video.

If you know of a better way of doing this let us know in the comments below.

File attachments: 

Comments

Whether you’re writing an essay for Marketing, Management, Finance or any other subject related topic, following certain guidelines can help you develop a piece of work that is well structured. The most important considerations for essays are that it present relevant content and its arguments are supported by qualified references or examples. Other critical factors include layout, presentation and use of appropriate languages. Before you start writing the following steps should consider.
1. Analyze the essay question
2. Research the material for your essay
3. Make an outline plan for your essay

To write an essays a first compose draft of your essay according to the structure of your outline plan. Try to use clear, precise languages and constructive business terminology to put your points across, but on every account avoid the use of jargon. The following essay format is recommended to present your work logically. It’s not necessary to include all components, only those that add value to the paper. Following are the format of preparing essays
1. Introduction
2. Background
3. Findings
4. Conclusion
5. Bibliography
6. Appendices

Source: Academic essay review site

Post new comment