View displaying field collection items based on taxonomy term

I have a set of nodes that include a field collection item GeoImages. (Each node can contain multiple Geoimages, if that’s relevant).

Geoimages includes (among other fields) an Image and and Image tags field (which relates to an Image Tags taxonomy).

When viewing a node including the GeoImages field collection, I want to click on a tag associated with an image and see the GeoImages field collection items with the same tag.

When I click on a tag within a GeoImage (say Image Tag1), I navigate to the path:[site]/image-tags/image-tag1 — which shows a page title of “Image tag1” but no content.

I have created a view to view field-collection-items as below. When I preview the Page with with the contextual filter sat to “Image tag1” it shows a path of image-tags/Image tag1 and shows the desired content… Ditto if I set the contextual filter to image-tag1.

What blindingly obvious thing have I missed?

[I will kick myself when I get an answer but I’m banging my head against a brick wall right now, so kicking myself will be less deleterious.]

$view = new view();
$view->name = 'image_tags';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'field_collection_item';
$view->human_name = 'Image tags';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Image tags';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'entity';
/* Relationship: Field collection item: Entity with the GeoImages (field_geoimages) */
$handler->display->display_options['relationships']['field_geoimages_node']['id'] = 'field_geoimages_node';
$handler->display->display_options['relationships']['field_geoimages_node']['table'] = 'field_collection_item';
$handler->display->display_options['relationships']['field_geoimages_node']['field'] = 'field_geoimages_node';
$handler->display->display_options['relationships']['field_geoimages_node']['required'] = TRUE;
/* Relationship: Field collection item: Image tags (field_image_tags) */
$handler->display->display_options['relationships']['field_image_tags_tid']['id'] = 'field_image_tags_tid';
$handler->display->display_options['relationships']['field_image_tags_tid']['table'] = 'field_data_field_image_tags';
$handler->display->display_options['relationships']['field_image_tags_tid']['field'] = 'field_image_tags_tid';
$handler->display->display_options['relationships']['field_image_tags_tid']['required'] = TRUE;
/* Field: Field collection item: Field collection item ID */
$handler->display->display_options['fields']['item_id']['id'] = 'item_id';
$handler->display->display_options['fields']['item_id']['table'] = 'field_collection_item';
$handler->display->display_options['fields']['item_id']['field'] = 'item_id';

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Contextual filter: Taxonomy term: Name */
$handler->display->display_options['arguments']['name']['id'] = 'name';
$handler->display->display_options['arguments']['name']['table'] = 'taxonomy_term_data';
$handler->display->display_options['arguments']['name']['field'] = 'name';
$handler->display->display_options['arguments']['name']['relationship'] = 'field_image_tags_tid';
$handler->display->display_options['arguments']['name']['default_action'] = 'empty';
$handler->display->display_options['arguments']['name']['title_enable'] = TRUE;
$handler->display->display_options['arguments']['name']['title'] = '%1';
$handler->display->display_options['arguments']['name']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['name']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['name']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['name']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['name']['limit'] = '0';
$handler->display->display_options['arguments']['name']['case'] = 'ucfirst';
$handler->display->display_options['arguments']['name']['transform_dash'] = TRUE;
$handler->display->display_options['path'] = 'image-tags/%';

The generated query is:

SELECT field_collection_item.item_id AS item_id
FROM 
{field_collection_item} field_collection_item
INNER JOIN {field_data_field_geoimages} field_data_field_geoimages ON field_collection_item.item_id = field_data_field_geoimages.field_geoimages_value
INNER JOIN {node} field_geoimages_field_collection_item ON field_data_field_geoimages.entity_id = field_geoimages_field_collection_item.nid
LEFT JOIN {field_data_field_image_tags} field_data_field_image_tags ON field_collection_item.item_id = field_data_field_image_tags.entity_id AND (field_data_field_image_tags.entity_type = 'field_collection_item' AND field_data_field_image_tags.deleted = '0')
INNER JOIN {taxonomy_term_data} taxonomy_term_data_field_data_field_image_tags ON field_data_field_image_tags.field_image_tags_tid = taxonomy_term_data_field_data_field_image_tags.tid
WHERE (( (taxonomy_term_data_field_data_field_image_tags.name = 'image tag1') ))
LIMIT 10 OFFSET 0
This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

View displaying field collection items based on taxonomy term

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.