Forum OpenACS Q&A: Re: Random photo from photo-album?

Collapse
Posted by Robert Locke on
Hi Jade,

I don't think it's been folded into CVS.

Regarding the first part of your question, I've never done it, but poking into Jeff's code, you could use the photo-album/www/photo.* page as a model.

The idea would be to create a simple "include" that would return the image tag for the photo.

First, change the query in photo.xql:

* remove the "ci.item_id = :photo_id"

* add a security check in the where clause:
    and acs_permission__permission_p(ci.item_id, :user_id, 'read') = 't'

* grab a random image by appending:
    order by random()
    limit 1

Copy the relevant parts of the adp (ie, the image tag plus admin links if you want).

Caveat: the query would cut across all photo-album instances.  Also, since the image tag will be included potentially from another page/package, you will need to give the fully qualified URL for the image (ie, starting at /photos or wherever photo album(s) is mounted).  I think you could do this by extending the query to join with cr_folders and site_nodes.  Or if you're in a rush and you have only one photo album mounted, hard-code it as a parameter to the "include" (bad but easy).

Hope that helps.  Let me know if you would like me to work on the code and send it your way.