Drupal 7 Album Folders for Field Gallery
Up to now we have been using a single page to contain all our galleries, which is soon going to fill up for those of us who take plenty of snaps. So in this tutorial we will be offering the option of creating a content type called Field Gallery Album to house selected galleries and provide a page to fit thumbnails for each album.
We will be creating Views Displays for the albums and associating the Views Displays with View Modes from the contents manage display settings.
- Cloning Views
- Views Contextual Filters
- Views Relationships
- View Modes
- Create the new content type "Field Gallery Album"
- Go into the Field Gallery content's Manage Fields settings, edit the node reference url and add the content type Field Gallery Album that can be referenced.
- Now's a good time to create some 'Field Gallery Albums' and some 'Field Galleries' for those Albums so we can test our Views and View mode configurations.
- Go into views, and make a clone of the Field Gallery View, I'm going to call mine 'Field Gallery Albums'
- Delete or disable the 'field gallery' display.
- Go into the Album view, change the Entity Content Settings bundles to the Field Gallery Album type
- Change the pager settings to display the specific number of items as 1.
- Add a new Page Display, I'll call mine 'Field Gallery Albums' Page and set the path to Albums.
- Change the Format to Grid and settings to the numbers of columns you want and the Show: to Content | Teaser
- And in the Filter section change the Content Type to Field Gallery Album.
- Go to the Album Display, we need to create a Contextual Filter to ensure only the correct galleries are displayed in the Field Gallery Albums. Add a Contextual Filter and select the Node Reference URL from the Field Gallery content type and enter the settings for the Validator as such
- Go to the Album Display in the Field Gallery view and make sure that the Field Gallery Album Bundle is added to the Entity Content Settings.
- Create a new menu item in the main menu, I'm calling mine "Field Gallery Album" and enter the path from your page view, which in my case was "albums'.
Now if you go to your newly created menu you should see both your views displays such as this
We are seeing both view display outputs because currently the manage display settings for the "Field Gallery Album" content type 'Manage Display' settings are set to display both.
- Go into the 'Manage Display' settings and make the Field Gallery views's display hidden.
Now we should only see the single thumbnail, but it is currently linking directly to the Field Gallery view of the Albums containing the Field Galleries, we need to redirect the link to the Field Gallery and we can remove the title of the Field Gallery.
- Go back into the view that generates the single image and add a relationship using the Field Galleries node reference.
- Add a Content: Nid field, use the relationship that we just created and select 'exclude from display'. This is going to be used to hold the address of the Node Gallery Album which is where we want to relink to. Here are my setting for the Nid field.
- Rearrange the fields so Content: Nid is above the image field.
- The title field can now be removed or excluded from the display.
- Open the image field. Remove the link in the Formatter section. Select 'REWRITE RESULTS' and then 'Output this field as link'. Scroll down and get the Content: Nid token and insert it into the 'Link Path'. Note we will prefix the text "node/" in front of the token. Below is an example of the settings for this field.
For the Field Gallery Albums we will need to ensure that the View Mode generated from the Field Gallery View is made visible. I'll add the "Full Content" View mode to set this. Now currently only the Field Gallery Albums view is available.
- Now when viewing the Field Gallery Albums we are seeing every Field Gallery instead of the Field Galleries that belong in this Album.
- Add a Contextual Filter in the Album Display of the Field Gallery View that will only display the Field Galleries connected by the node reference url in the Field Gallery content type as such
- Check that the Arguments: id is enabled in the 'Entity Content Settings'
As well as giving you the benefit of creating any number of Albums to house your galleries, you will also have been given good exposure to some of views more advanced techniques in the form of Contextual Filters and Relationships as well as utilizing View Modes.
- New post: Posting location co-ordinates to a drupal service - Part 2 http://t.co/MQhlVKBNKC — 1 month 5 days ago
- New post: Posting location co-ordinates to a drupal service - Part 1 http://t.co/2xlYgqFaJ0 — 1 month 5 days ago
- New post: Connecting a drupal service with a mobile application - Part 2 http://t.co/01cFtAunDs — 1 month 5 days ago
- New post: Using drupal services to connect to mobile applications - Part 1 http://t.co/VEURftHCef — 1 month 5 days ago
- New post: Creating Drupal 7 video gallery http://t.co/HvpKU7uT — 3 months 1 week ago