I want to be able to add a gallery for each user. I understand how to create a content type. I considered building an image content type. I then thought I could add a view which would only display each user.
Is this best practice for creating a gallery for each user?
I am using Drupal 7, if this makes any difference.
I can get it working in a view but it doesn't seem to work in a block
Yes, you are on a right path. The Views module, and content types can be used to build a simple gallery for a user.
Create a content type called Image Gallery.
Add a image field to above content type.
Create a view called user gallery.
Filter by Content Type Image Gallery.
Filter by Node author: Logged in user, if you want to show logged in users Gallery.
Add the contextual filter Author UID, if you want to dynamically pass the user ID from the URL and filter the Gallery Images.
For above your view page path should be user-gallery/% where % will be user id.
The answer shows how you can control the output of a block so for example each user gets a different gallery. I found out this method for drupal 6 views 2. http://drupalsn.com/learn-drupal/drupal-questions/question-2650
Herexe2x80x99s how ixe2x80x99d do it: 1) In the view admin page under arguments click on the User:name argument and scroll down the page where youxe2x80x99ll see some options for that argument under xe2x80x9cBlock: Configure Argument User: Namexe2x80x9d.
2) Under xe2x80x9cAction to take if argument is not presentxe2x80x9d select xe2x80x9cProvide default argumentxe2x80x9d then under xe2x80x9cDefault argument typexe2x80x9d select xe2x80x9cPHP codexe2x80x9d now we can enter some custom PHP code to get the username from the page URL assuming your username is the second argument in the URL ie. publications/USERNAME
3) Now in the xe2x80x9cPHP argument codexe2x80x9d box enter the following PHP:
Again Ixe2x80x99m assuming the URL is publications/USERNAME and what we are saying here is if the first URL argument is xe2x80x9cpublicationsxe2x80x9d and the second URL argument is not blank then use the second argument as the views username argument. 4) You should select xe2x80x9chide view / page not foundxe2x80x9d in the xe2x80x9cAction to take if argument does not validatexe2x80x9d under xe2x80x9cValidator optionsxe2x80x9d that way views will check the user exists and find the view/block is they donxe2x80x99t have any content.
5) Lastly save the view and assign your block to the publications/USERNAME page.
That should do it, let me know if it works, i loaded up views and tested it so should be fine.