We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47633
    • 11 Posts
    Hi all.
    I'm looking at making a gallery on a website. This will have many albums, containing photos. I would like to individually protect albums with a password/passcode and was just wondering if this is possible.
    I don't want to have a user login system where users sign up. It would be suffice for the admin to create the album, assign it a password, which could then be given to whoever requires access.

    I've looked at packages such as DocPassword and Pagelocker, which can assign a password to individual pages, but gallery uses the same page with URL parameters so I don't think these will work.

    Just looking for a heads up if anyone else has implemented this sort of functionality so that I can save myself some time.

    Thanks a lot!
      • 20371
      • 58 Posts
      I've never done this exactly.. but I have a few thoughts.

      I'd use the built in user management in MODx, I found ACLs (permissions) in MODx to be really complicated, but I have a feeling that this route will give you the most robust, secure, and versatile solution. It might be worth putting the extra time in now to save the drama later. You wouldn't need to make user sign-up pages or whatever, just configure users yourself from the manager and make a simple log-in log-out.

      Anyhow, whether you use MODx users or page locker or some such.. set up your Gallery call so that the album isn't pulled from URL parameters, and have a specific resource (page) for every album. That will make it easier to sort out your permissions.. so the gallery call would like like [[Gallery? &album=`[[*galleryName]]`]] where you've created a TV 'galleryName'.

      It's worth saying that any of these methods aren't really 'secure' per se. Gallery calls phpThumb which dumps the images in a cache folder, from where they can be accessed directly without logging in. There's probably ways to avoid this, but there might be other security considerations.

      To be honest, I'd very seriously consider a stand alone Gallery project because you have a good chance of appropriate security, and won't have to pfaff around setting up logins.
        • 47633
        • 11 Posts
        Thank you for your suggestions. The project as been pushed back a bit so I've taken a break from it, but I'm looking at it again.

        I don't really care about ultimate security for this project, the images aren't secret or anything, it'd just be good to have a way to restrict some albums.

        I think I'll go down the PageLocker route. Mainly because if I use MODx permissions, it'll be more work and that won't actually solve the issues to go with automating the process.
        I've now set up PageLocker (Created my login page/Added TVs to gallery template).

        That works fine in that galleries I give a password are now passworded.

        I now just need to automate it so it's easy for the client to use. Currently they'd have to upload images in Galleries, create a new page and insert the [[!Gallery]] snippet. I want to be able to make it so when I create the gallery, the page is created and passworded (if required).
        It'd be really useful if gallery had the ability to define post-hooks, like FormIt. If it fired when a gallery was created I could write a snippet to create a resource, set the password via the TV and put in the shortcode.
        Unfortunately it doesn't look like that exists :/
          • 47633
          • 11 Posts
          I have created a (sort of) solution to this. It's not brilliant, but it worked for the project I was working on so thought I'd share, in case it's useful to anyone else. If anyone has any ideas or suggestions to make it better, or even a completely different method, I would be very grateful - Just thought I'd share what I got!

          I've written a post about it on my blog because I felt it was a bit big to put here:

          http://terfmop.co.uk/blog/2014/07/22/how-to-create-a-password-protected-gallery-in-modx/