By joshua_cohen on
Is there an easy way to have a block showing X number of thumbnail's from a gallery of a group? It seems like a job for Views, but I'm not sure how it might be accomplished. I basically am looking to have a block displayed in every group showing the first 3 images from the "Main" gallery.
Thank You,
Josh
Comments
Solved
I have figured out how to do this using the great Views module. If anyone is interested, I will post instructions on how to make it happen.
Josh
YES!
Great job Josh!
Please post your instructions... i could really need them!
Finn
Instructions
Ok I'll try to describe this as best I can. First, this is intended for use in Drupal 5.x, with the latest version of OG, OG Galleries, and Views. I will assume that you already have OG up and running and have configured OG Galleries using the default gallery name of "Main". Second, and this is a big one, I have not actually used this in a Block, instead I have decided to place the latest 3 images on the Group homepage node. Just edit the Group node making sure to use the PHP option and paste in this snippet:
I make no claims that this is the best way to make this happen, but it worked for me. First, this code makes the assumption that the current node being viewed is a Group node, which in this case it always will be since it's on the Group homepage node, hence the arg(1) calls. The SQL query is being used to lookup the term id of the "Main" gallery associated with this group. I then call the views_get_view and views_build_view to get the default og_galleries view using the term id found earlier and limit the results to 3 images. I have not tried it, but this code should work in a block as well. Just create a new block and paste in the code. You may want to add some code to check if the current node is a Group node and hide/display the block accordingly.
Hope this helps,
Josh
How could i tweak this code
How could i tweak this code to show a block with thumnails on the homepage of the site?