HowTo: Create a Shared Gallery

Last updated on
30 April 2025

You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules

There are two ways to stop people from editing the gallery title and description, one with rules and another with path redirect. The path redirect is easier or requires fewer settings.

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)
  • path_redirect
  • 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.

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

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)

Using path redirect instead of rules

You can use a workaround with the path_redirect module if you don't want to use rules. What this will do is -- if the user tries to click the 'edit' tab for the gallery, it will redirect them to the gallery. In effect, they will not be able to edit the gallery title, description or any other items on the gallery edit page.

In the path_redirect interface, set a redirect from:
http://www.example.com/node/51/edit
to
http://www.example.com/node/51
This is just an example path, change the '51' to the node that your gallery is using.
To see the node number right click the gallery edit tab and choose properties and redirect that url to the gallery they are using. The path you will redirect to will depend on url aliases and/or pathauto if you use those.

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

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.


Help improve this page

Page status: Not set

You can: