如何从出口页面的元标记中获取令牌值 - Drupal 7?

How to get the token value from meta tag in a outlet page - Drupal 7?

我需要显示元标记令牌中的元标记值。

我的代码:

function MyModule_html_head_alter(&$head_elements) {
    $head_elements['metatag_description']['#value'] = $outlet_description; 
}

实际输出:

[node:node_sections] - [node:field_lead_text] Testing

预期输出:

   Food - Testing lead text Testing

你必须使用token_replace函数

$menu = menu_get_item();
  if($menu['path'] == 'node/%') { // check if you are on node page
    $node = $menu['page arguments'][0];
    $head_elements['metatag_description']['#value'] = token_replace($outlet_description, array('node' => $node));
  }