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.
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.
Create two views. One view will display all team members and the other view will display the individual users or team member.
- Create a new view that shows "Users" instead of "Content".
- 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.
- 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.
- 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.
- Create another view for the individual
- Add any additional fields you want to show. You can think of this page as the profile page for the user
- Set the path to "team/%".
- 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.