-1

I work on drupal 7, In content type add New field type field collection. Add content and use meta tag. In content page (node) meta tag display properly, In field collection page field-collection/field-name/id content display proper, we want to add meta tag (title, description, etc) of every field collection page.

0

2 Answers 2

0

Using the metatag module, and context module, and the metatag content submodule thats bundled with metatag, you can assign metatags by nid or url. The problem would be that it wouldnt do this programmatically, but might be a quick fix if you havent got that many pages.

As far as I know, there isn't a way to use metatag to generate metatags based on tokens and patterns for a field collection.

0

By default, metatag support is disabled for field-collection-items. You can enable it by writing your own custom module implementing hook__metatag_entity_type_is_supported_alter() (see below). After enabling the custom_module (or cache clear), you should be able to enable/disable metatags for field-collections under admin/config/search/metatags/settings. The field-collection metatag form elements won't appear on the host entity form (i.e. node form), but on the field-collection edit form.

In my use-case I set the metatag values via the host-token to the host entity values, if an editor needs to set different values for a field collection item he needs to edit this particular item.

/**
 * Implements hook_metatag_entity_type_is_supported_alter()
 *
 * Enable Metatag support for field-collection-items, to be able to set metatags
 * for gallery field-collection-items.
 */
function custom_module_metatag_entity_type_is_supported_alter(&$suitable, $entity_type, $entity_info) {
  // Enable Metatag support for field_collection_item's previously disabled in
  // metatag_entity_type_is_suitable().
  if ($entity_type == 'field_collection_item') {
    $suitable = TRUE;
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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