diff --git a/metatag.module b/metatag.module index 4672c65..222ebef 100644 --- a/metatag.module +++ b/metatag.module @@ -1404,8 +1404,17 @@ function metatag_metatags_form(array &$form, $instance, array $metatags = array( if ($form['metatags']['#access']) { // Check if each meta tag group is being displayed. if (!empty($group_metatag_access)) { - // Built the token browser link. - $token_listing_link = theme('token_tree', array('token_types' => $options['token types'], 'dialog' => TRUE)); + // Built the token browser link. For value "all" theme_token_tree() + // compares with string, not array. + if (in_array('all', $options['token types'])) { + $options['token types'] = 'all'; + } + $token_listing_link = theme('token_tree', + array( + 'token_types' => $options['token types'], + 'dialog' => TRUE + ) + ); foreach ($group_metatag_access as $group_key => $token_access) { if ($token_access) { diff --git a/metatag_context/metatag_context.admin.inc b/metatag_context/metatag_context.admin.inc index 474f90e..256ebe3 100644 --- a/metatag_context/metatag_context.admin.inc +++ b/metatag_context/metatag_context.admin.inc @@ -105,7 +105,9 @@ function metatag_context_config_edit_form($form, &$form_state, $context) { // Don't care about the instance name, the data is being managed by Context // and not Metatag. $instance = ""; - $options = array(); + $options = array( + 'token types' => array('node', 'term', 'user'), + ); $metatags = $context->reactions['metatag_context_reaction']['metatags']; if (!isset($metatags[LANGUAGE_NONE])) { @@ -149,9 +151,6 @@ function metatag_context_config_edit_form($form, &$form_state, $context) { '#weight' => -99, ); - // Show all tokens. - $form['metatags']['tokens']['#token_types'] = 'all'; - $form['metatags']['#type'] = 'container'; unset($form['metatags']['#collapsed']); unset($form['metatags']['#collapsible']); diff --git a/metatag_context/metatag_context.context.inc b/metatag_context/metatag_context.context.inc index fca934b..4fad861 100644 --- a/metatag_context/metatag_context.context.inc +++ b/metatag_context/metatag_context.context.inc @@ -26,8 +26,10 @@ class metatag_context_reaction extends context_reaction { ); } - // No options currently available. - $options = array(); + // Provide token types. + $options = array( + 'token types' => array('node', 'term', 'user'), + ); $form['help'] = array( '#prefix' => '

', @@ -139,6 +141,16 @@ class metatag_context_reaction extends context_reaction { $instance = 'context:' . implode(',', $instance_names); $options['instance'] = $instance; + // If an entity & entity type were saved elsewhere, grab them for later. + // @see hook_entity_prepare_view(). + $entities = drupal_static('metatag_context_entities'); + if (!empty($entities) && (count($entities[1]) == 1)) { + $data = array_values($entities[1]); + $options['entity'] = $data[0]; + $options['entity_type'] = $entities[0]; + $options['token data'] = array($entities[0] => $data[0]); + } + // Don't output meta tags that only contain the pager. $current_pager = metatag_get_current_pager(); diff --git a/metatag_context/metatag_context.module b/metatag_context/metatag_context.module index 6b2d58f..4ca1e95 100644 --- a/metatag_context/metatag_context.module +++ b/metatag_context/metatag_context.module @@ -82,6 +82,14 @@ function metatag_context_context_page_reaction() { } /** + * Implements hook_entity_prepare_view(). + */ +function metatag_context_entity_prepare_view($entities, $entity_type, $langcode = NULL) { + // Store the current entities. + drupal_static('metatag_context_entities', array($entity_type, $entities)); +} + +/** * Implements hook_page_build(). */ function metatag_context_page_build(&$page) {