I have a custom entity through Entity API. I can configure metatags for it. But they don't show on the page (only global metatags).

When I look at metatag_field_attach_view_alter() it's attaching the metatags correctly. $output['metatags'] = $cache->data; gives exactly the metatags I need, except they are never part of $my_entity->metatags (always empty array()).

I guess there is a missing link somewhere? The field is attached correctly, but remains empty after a entity_load();

Comments

Anonymous’s picture

I got it working by adding this to my template_preprocess_{entity}()

    $variables['metatags'] = array();
    if (module_exists('metatag')) {
      $context = array(
        'view_mode' => 'full', 
        'entity_type' => 'my_entity', 
        'entity' => $my_entity,
      ); 
      metatag_field_attach_view_alter($variables['metatags'], $context);
    }

And then in entity-full.tpl.php I created:

render($metatags);

Sure this is not the "right way", but a last resort for me.

jessepinho’s picture

Were you ever able to figure this out without the hack-y method? I'm having the same problem myself.

damienmckenna’s picture

Status: Active » Postponed (maintainer needs more info)

I believe this should work out-of-the-box now, once you enable meta tags for your custom entity.

damienmckenna’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

Thanks to amazing work by Marcin Pajdzik, we will be handling the by-path functionality via #1187710: Integrate with Context.