Hi Dave,

I am the maintainer of the Content Analysis module. I am working on integrating Meta tags into the analysis. I have been digging through your code with little success so its time to ask for directions.

What is the best way to get the rendered title, description and keywords values for a node? I am needing a way to pass a node object or the meta tag values from a node edit form to some function and get back the outputted values.

Thanks,

Tom

Comments

TomDude48’s picture

I came up with a solution. If you get a chance can you look at the code and see let me know if there is a better way to do this. BTW, I love the way you have re-worked this module. The ability to have layers of inheritance and use tokens is much apprecitated.

Code:

    $options = array(
      'entity_type' => 'node',
      'entity' => $context['node'],
      'view_mode' => 'full',
      'display_mode' => 'full',
      'token data' => array(
        'node' => $context['node'],
      )
    );
    $metatags = array(
      'title' => array(
        'value' => $context['meta_title'],
      ),
    	'keywords' => array(
        'value' => $context['meta_keywords'],
      ),
      'description' => array(
        'value' => $context['meta_description'],
      ),
    );
    $ret = metatag_metatags_view('node:' . $context['node']->type , $metatags, $options);  
  
    $context['meta_title'] = $ret['title']['#attached']['metatag_set_preprocess_variable'][0][2];	
    $context['meta_keywords'] = $ret['keywords']['#attached']['drupal_add_html_head'][0][0]['#value'];
    $context['meta_description'] = $ret['description']['#attached']['drupal_add_html_head'][0][0]['#value'];
damienmckenna’s picture

Component: Code » Documentation

This should be documented.

damienmckenna’s picture

Issue summary: View changes

making a little clearer