You are here

function fb_graph_preprocess_page in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 6.3 fb_graph.module \fb_graph_preprocess_page()

Implements hook_preprocess_page().

Adds our meta tags to the html header.

File

./fb_graph.module, line 214
Open Graph Helpers

Code

function fb_graph_preprocess_page(&$vars) {
  $tags = fb_graph_get_tags(TRUE);
  if (count($tags)) {
    foreach ($tags as $key => $value) {
      if (is_array($value)) {

        // Arrays represent multiple properties for same key.  I.e. og:image
        foreach ($value as $val) {
          drupal_add_html_head(array(
            '#tag' => 'meta',
            '#attributes' => array(
              'property' => $key,
              'content' => $val,
            ),
          ), $key);
        }
      }
      else {
        drupal_add_html_head(array(
          '#tag' => 'meta',
          '#attributes' => array(
            'property' => $key,
            'content' => $value,
          ),
        ), $key);
      }
    }
  }
}