Community Documentation

Multiple galleries and taxonomy

Last updated May 22, 2010. Created by AndiS on October 1, 2007.
Edited by john.kenney, add1sun. Log in to edit this page.

Here's another method for multiple galleries, using taxonomy for HowTo: Create an image gallery using only CCK and Views.
You need one additional module: http://drupal.org/project/viewfield

I wanted the site editor to be able to create an additional gallery like he would create any other content, without having to add additional views or vocabulary terms.

The first steps are identical to "Adding Taxonomy" shown above:

1. Go to Administer/Categories (admin/content/taxonomy)

2. Click the 'Add Vocabulary' tab

3. Call the vocabulary 'Image Gallery'

4. In the 'Types' section, check the checkbox next to the CCK content type you created for images (mine is called 'Image')

5. Once the vocabulary is created, add terms to it - or select "Free Tagging": this will allow the admin to start a new gallery without having to define it in the Categories Administration first.
Now when you go to create or edit an image content type, you will see an auto-complete field where you can enter the name of the gallery you want it to be displayed in.

6. Now go back to the View you created before for your gallery (admin/build/views), and instead of adding a filter, add an argument:
Taxonomy: Term Name

7. Create a new Content Type, called "gallery"

8. Add a field to "gallery", for the Field Type select "View Reference"
as the Default Value, select the View you created before for your gallery.

9. Now go to Create content & create a new gallery. You can give it a title, and enter some description to the body if needed.
As an argument, enter any tag you assigned to your pictures before, for example the gallery name. Every picture that has been tagged with that term will show up in that gallery.

10. To display all the galleries on one page, you need to create one last View (admin/build/views)

choose Add

Name e.g. "allgalleries"

- Page:
check Provide Page View
URL: wherever you want it to show up
View Type: Full Nodes (You can of course adjust this to just give you links to the seperate galleries, or show teasers, etc.)

- Filters:
Node: Published - Equals - Yes
Node: Type - Is One Of - gallery

11. To create one or multiple master galleries displaying some, but not all of the subgalleries, you need to modify the View from #10 and then clone it for as many versions as you need. For instance on an artist's site where you want art galleries in one place and, maybe, photos of art events/exhibits in another, you need to create 2 new views for that.

First, add a new filter to the View in #10: Taxonomy: Term = 'term_x'. Second, modify path and menu options, as appropriate. This will create a page showing only gallery pages in the taxonomy 'term_x'.

Then, if you need multiple such pages, clone the updated View and change the taxonomy term accordingly (term_y). Edit path and menu to match.

To get an image thumbnail to show on these master galleries (both here and for #10), you can add CCK 'imagefield' to your gallery_page and upload whatever image you want. There may be a way to make this image be the 'most recent', but i couldn't figure it out.

Also, step #11 requires that your taxonomy has the necessary terms x and y. Meaning that you'll generally need at least 2 levels in the hierarchy: all_galleries -> gallery_type -> subgallery. So gallery_type might be 'art' (term_x) vs. 'events' (term_y) with subgalleries underneath each.

------------

That's it. Instead of creating a content type called gallery (in #7), you could add a View Reference field to any content type, so you could display an image gallery in any node. E.g. a blog article about your last vacation could show all pictures tagged with "Rome" and "5-6-07".

The end result isn't revolutionary, or that different from the original How-To, but this way any user / editor who knows how to create content (or whose permissions restrict them to just that) can start a new gallery. Hope it helps.

Comments

Problem

I've followe each of these steps paying great attention each and every time, yet can't get it to work. Any "Photo gallery" content type I create shows all photos of node type "Photo" irrespective of the terms I'm associating with both the photo galleries and the individual photos. Does anyone have any idea what the issue is here as I really want to get my galleries working in this fashion.

Kind regards,
D.

Did you attached the View

Did you attached the View field to the Photo gallery content type and selected which View you want to use?
Try to describe exactly what you did. For me it worked without any problem.

Catogorizing the Images

Thanks for the post. This shows all images. How can you catogorize the images?

or in other words, show the first image in the main category or show based on weight.

I'm using taxonomy image to show the images. But I want to only show the top category. Then on click, goto the subcategories.

thanks!

bredi

Hi, I've got problem with

Hi,

I've got problem with cck gallery address. im my page (drupal 6) each user can create his own couple gallery's.
I have to put in user profile address which take us to his list of gallery, and here is the problem. how can I crate a this list of gallery's, which is categorized by name of users (that the address would be www.example.com/gallery/user-name)??

Thanks for help
Piter

Fantastic!

This method works absolutely great. Thanks for posting this.

Having the ability to specify the relevant taxonomy term in the node using the viewfield module (as opposed to in the view directly) makes life a lot simpler - especially when you have multiple types of galleries to organize.

imo, this approach is superior for this purpose than Views Gallery module which is not very flexible (e.g., you can't move an image from one gallery to another very easily). also, i could not actually figure out how to do multiple gallery types in that module. i don't think it is possible.

I added a new step #11 to describe how i modified the approach to support multiple 'master' galleries where each master gallery shows subgalleries in a certain taxonomy.

Need advice on Step 8

Hi John. I am stumped by step 8. How can I select "View Reference" when creating a content type called "gallery"?

Step 8 ?

I am baffled by Step # 8. When creating a new content type called "gallery", there is no selection for "View Reference".

Then Step #8 said to use as a default value, "select the View you created before for your gallery". There is no place in the content type creation where I can select any view.

What am I misinterpreting in the directions?

...

the whole thing relies on having the viewfield module installed. you've done that?

since step #8 depends on the other steps, it is hard to guess where things are awry.

but here are 2 screenshots that may help you along.

http://img815.imageshack.us/img815/2528/gallerypagemanagefields.png
http://img808.imageshack.us/img808/60/gallerypagecreate.png

...

maybe you need to see the field settings, too.

http://img821.imageshack.us/img821/8441/gallerypageviewfield.png

Thank you

Thanks, John, for the amazingly rapid response. I will try to match up my form to your screenshots. I really appreciate it.

P.S. The thought did occur to me that maybe the viewfield module did not get installed but I checked and saw it in place.

...

mostly lucky timing. :) but you're welcome and good luck.

Lucky

Yes, lucky for me.

While using your screen shots I now realize the directions said "View Reference" when in fact it should be "View Field".
Arggghhhh. I am so glad I got your help on this.

Thanks anyway

I did steps 1 to 9 over and over again but by the time I got to step #9 I got no gallery displayed at all. I am grateful for the quick support you gave me.

argument

I got everything working except for the arguments (I'm using D6 and Views 2 respectively).
The galleries always show all the images, regardless of taxonomy.
Can anybody please share the exact options for the taxonomy term argument?

...

for taxonomy term, i think the options are simply the default options. i have made no changes on my site.

you are sure you have the 'gallery' content type set up correctly and there is a field in that content type where you enter the actual 'argument' - i.e., the specific taxonomy term.

i guess that is what you are saying, that regardless of what taxonomy term you enter in a 'gallery' page, you get the complete set of images.

not sure if this would help

not sure if this would help anyone, but i was having the same problem this morning, and thought something must be missing... well sure enough, when i went back and read through the directions again, and it seemed i had not actually set up the "argument" property in views correctly:

(ie: #6 above)

when i finally set it up, it for some inexplicable reason took about 20 page refreshes before it worked. caching is off, so i'm not sure why it didn't work instantly - something about taxonomy?

in any case, thanks for this tutorial - it works great now!

dylan

Site Building Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here