HowTo: Create a Shared Gallery
Give users ability add images to a gallery they did not create, or a Shared Gallery
Lets say you have a scenario where you want to create an album/image relationship that will serve as a photo competition. Users must then have the ability to post images in this gallery, even though they have not created the gallery. They may need to edit or update their own images and add a title with a description for each image as well. Users must not be able to create galleries with this relationship and we do not want them to change the Title or Description associated with the Gallery. Lightbox2 can be used with the shared gallery if desired.
Note: This setup may not be needed in the future as the module matures. But we don't have to wait because we can do it now! Drupal is Cool...
- Modules used in this example:
- node_gallery
- CCK(Content Construction Kit)
- content_access (requires rebuild permissions on install)
- rules Allows site administrators to define conditionally executed actions based on occurring events.
- masquerade (optional) This allows you login as admin and switch to a registered user. Used for posting test content and is a good way to edit a user image while keeping the uid for the image intact.
This is the node gallery relationship to be used for sharing
Create 2 new content types, for gallery and image nodes. (normal gallery relationship set up)
Note: A new Gallery Content Type
is required, but an existing Gallery Image Content Type can be reused. The existing ImageCache presets can be reused or create new presets. When this has been done, set the permissions for the new shared gallery.
Permissions have been granted to all roles in this example:
Goto: Administer > User management > Permissions
system path: admin/user/permissions
- view imagecache node-gallery-cover
view imagecache node-gallery-display
view imagecache node-gallery-thumbnail
create photo_competition_gallery content
create photo_competition_image content
edit any photo_competition_gallery content
edit own photo_competition_image content
view node gallery
Prepare the gallery for rules to prevent users from changing the Title and/or the Description
Goto: Administer > Content management > Content type > photo_competition_gallery
System path: admin/content/types/photo-competition-gallery
Remove the text in the core body or description field to disable.
Add a new CCK text area field for description.(photo_comp_description) This is needed for rules to work properly.
Create the new shared gallery to hold the images.
Goto: Administer > Create content > photo competition gallery
System path: admin/node/add/photo-competition-gallery
Enter the Title of the gallery new photo competition title
Enter the description of the gallery new photo competition description
After the shared gallery is created.
Set triggered rules to retain the original Title and/or Description if a user edits them
Goto: Administer > Rules > Triggered rules > Add a new rule
System path: admin/rules/trigger/add
- Add a new triggered rule:
(label)
whatever-- photocomp title
(event)
After updating existing content(save)
section Rule Elements:
(add a condition) Node: Content has type
(next)
(content types) photo competition gallery
(save)
section DO:
(Add an action) set content title
(next)
Enter your actual title text new photo competition title
(save)
-----------
Add a new triggered rule:
(label) whatever-- photocomp description
(event) After updating existing content
(save)
section DO:
(add an action) Populate a field
photo_comp_description_field
(continue)
Enter your actual description text new photo competition description
(save)
Set the content access for the Gallery Node
This is where the permissions magic happens. Each authenticated user that adds an image to the gallery will be able to edit their own images.
Note: This can also be set to allow permissions for specified users by user name
. This does not work well for anonymous users as they can edit any image submitted by another anonymous user (unless the edit permission is disabled).
Content access, set this for the user roles
to be included:
Goto: Administration > Content management > Content types > photo_competition_gallery > Access control
System path: admin/content/types/photo-competition-gallery/access
- View any content:
[X] anonymous user
[X] authenticated user
Edit any content:
[X] anonymous user
[X] authenticated user
View own content:
[X] anonymous user
[X] authenticated user
Edit own content:
[X] anonymous user
[X] authenticated user
Prevent users from creating a new shared gallery
We do not want users to create a shared gallery because the rules module is used for control of the Title and Description. If they create a shared gallery, the Title and description will change to the preset value in the triggered rules.
Goto: Administer > Site building > Menus > List
System path: admin/build/menu/list
Open the Navigation menu and un-check the shared gallery and image content types.
- In this example:
photo_competition_gallery
photo_competition_image
Note: A version of this setup using views can also be done and will be added after the details are documented or it is requested.
Thanks goes out to Manamarak for the motivation to get this documented for all to enjoy.


