0

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
  • What is the generated query? – Kevin Feb 17 '16 at 15:24
  • @Kevin, edited to show generated query – ColeValleyGirl Feb 17 '16 at 15:36
  • Something to me feels that the path argument isn't going to work for the filter because you're looking at the alias of the uri. – Kevin Feb 17 '16 at 16:10
  • @Kevin What confuses me is that the Views preview is correct and it works if I enter the url in the browser manually, but not when I click through from the content. – ColeValleyGirl Feb 17 '16 at 16:36
0

The Drupal module Taxonomy Display allows you to modify the behaviour when you click on a tag, to display a view of your choice rather than see the default Drupal term page (which doesn't work for field collection items).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.