0a1,18 > diff --git a/metatag.inc b/metatag.inc > index de7fa3a..85d0244 100644 > --- a/metatag.inc > +++ b/metatag.inc > @@ -313,9 +313,10 @@ class DrupalTitleMetaTag extends DrupalTextMetaTag { > */ > public function getElement(array $options = array()) { > $element = array(); > - $value = htmlentities($this->getValue($options), ENT_QUOTES); > - $element['#attached']['metatag_set_preprocess_variable'][] = array('html', 'head_title', $value); > - $element['#attached']['metatag_set_preprocess_variable'][] = array('html', 'head_array', array('title' => $value)); > + if ($value = htmlentities($this->getValue($options), ENT_QUOTES)) { > + $element['#attached']['metatag_set_preprocess_variable'][] = array('html', 'head_title', $value); > + $element['#attached']['metatag_set_preprocess_variable'][] = array('html', 'head_array', array('title' => $value)); > + } > return $element; > } > } 2c20 < index dfa9b82..e8036f1 100644 --- > index dfa9b82..d45442d 100644 5c23 < @@ -84,14 +84,14 @@ function metatag_context_context_page_reaction() { --- > @@ -84,25 +84,14 @@ function metatag_context_context_page_reaction() { 18c36,47 < + $page[$region]['metatags']['by_path'] = $metatags; --- > - } > -} > - > -/** > - * Implements hook_preprocess_html(). > - */ > -function metatag_context_preprocess_html(&$variables) { > - $metadata = drupal_static('metatag_context'); > - > - if (isset($metadata['metadata_title'])) { > - $variables['head_title'] = token_replace($metadata['metadata_title']); > + $page[$region]['metatags']['context'] = $metatags; 22c51 < @@ -115,3 +115,15 @@ function metatag_context_ctools_plugin_api() { --- > @@ -115,3 +104,15 @@ function metatag_context_ctools_plugin_api() { 30c59 < +function metatag_module_implements_alter(&$implementations, $hook) { --- > +function metatag_context_module_implements_alter(&$implementations, $hook) { 37a67,158 > diff --git a/metatag_context/metatag_context.test b/metatag_context/metatag_context.test > index d641fa6..cb3c7c6 100644 > --- a/metatag_context/metatag_context.test > +++ b/metatag_context/metatag_context.test > @@ -49,24 +49,56 @@ class MetatagContextTest extends MetatagTestHelper { > * Performs the basic tests. > */ > public function testMetatagContextBasic() { > - // Create content type node. > - $this->drupalPost('node/add/' . $this->hyphen_type, array('title' => $this->randomName(8)), t('Save')); > - $this->context_name = drupal_strtolower($this->randomName(8)); > + // Create a node and assign meta tags. > + $node_data = array( > + 'title' => $this->randomName(8), > + 'metatags[und][title][value]' => 'My node title', > + 'metatags[und][description][value]' => 'My node description', > + 'metatags[und][abstract][value]' => 'My node abstract', > + 'metatags[und][keywords][value]' => 'My node keywords', > + ); > + $this->drupalPost('node/add/' . $this->hyphen_type, $node_data, t('Save')); > + > + // Test meta tags on node. > + $metatag_object = $this->createMetatagObject('node/1', 'node_metatags'); > + foreach ($node_data as $key => $value) { > + // Extract meta tag type from key. > + if (preg_match("/metatags\[und\]\[(.*)\]\[value\]/", $key, $matches)) { > + $type = $matches[1]; > + $metatag_object->{$type} = $value; > + } > + } > + $this->checkMetatags($metatag_object); > > + // Create metatag contexts. > + $this->context_name = drupal_strtolower($this->randomName(8)); > // Generate metatags and check content. > - $this->metatag_pages['node'] = $this->createMetatagObject('node/1', 'node_metatags'); > - $this->metatag_pages['page'] = $this->createMetatagObject('', 'frontpage_metatags'); > + $this->metatag_pages['node'] = $this->createMetatagObject('node/1', 'context_node_metatags'); > + $this->metatag_pages['page'] = $this->createMetatagObject('', 'context_frontpage_metatags'); > foreach ($this->metatag_pages as $page) { > $this->generateMetatag($page); > $this->editMetatag($page); > + // Check meta tags. > $this->checkMetatags($page); > } > > - // Edit metatag and check content. > + // Edit title and check that it overrides the node title. > $this->metatag_pages['node']->title = 'New title'; > - $this->metatag_pages['node']->description = ''; > $this->editMetatag($this->metatag_pages['node']); > $this->checkMetatags($this->metatag_pages['node']); > + > + // Check that by clearing values on context, it will fallback to node meta tags. > + $node_metatag = $this->metatag_pages['node']; > + foreach ($node_data as $key => $value) { > + // Extract meta tag type from key. > + if (preg_match("/metatags\[und\]\[(.*)\]\[value\]/", $key, $matches)) { > + $type = $matches[1]; > + $this->metatag_pages['node']->{$type} = ''; > + $node_metatag->{$type} = $value; > + } > + } > + $this->editMetatag($this->metatag_pages['node']); > + $this->checkMetatags($node_metatag); > } > > /** > @@ -144,17 +176,19 @@ class MetatagContextTest extends MetatagTestHelper { > function checkMetatags($metatag_object) { > $options = array('description', 'abstract', 'keywords'); > $this->drupalGet($metatag_object->path); > + $this->assertResponse(200, 'Found path: ' . $metatag_object->path); > > foreach ($options as $option) { > - if (!empty($metatag_object->{$option})) { > - $this->assertRaw($metatag_object->{$option}, $option . ' found in ' . $metatag_object->path); > + if (isset($metatag_object->{$option})) { > + $xpath = $this->xpath("//meta[@name='" .$option ."']"); > + $this->assertEqual($xpath[0]['content'], $metatag_object->{$option}, 'Meta ' . $option . ' = ' . $metatag_object->{$option}); > } > else { > $this->assertNoRaw('