I can see my og: tags on the front page, but my views don't inherit from the global settings ... no tags are displayed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Status: Active » Postponed (maintainer needs more info)

What are you using to display meta tags with your Views?

aidanlis’s picture

Status: Postponed (maintainer needs more info) » Active

What do you mean? I want metatags to use the global settings ...

DamienMcKenna’s picture

@aidanlis: Do you mean that you're expecting the global meta tags to display on Views pages? Are they custom Views pages or are they entity pages being displayed using Views, e.g. taxonomy term pages?

aidanlis’s picture

They are custom views pages, and yes it'd be great if the defaults carried through. I see there's work going on in #1804356: Views integration: option to add meta tags within the Views UI which would make this request redundant, so happy for you to mark as duplicate if that's the way forward.

torrance123’s picture

They are custom views pages, and yes it'd be great if the defaults carried through.

That was my expectation too — I expected the global defaults to work on all pages unless a more specific metatag configuration existed (eg. for node pages, user pages, etc.).

Are there any foreseeable issues with switching to this behaviour?

torrance123’s picture

Status: Active » Needs review

This is one possible method to ensure all pages have, at a minimum, the global metatags set:

diff --git a/sites/all/modules/metatag/metatag.module b/sites/all/modules/metatag/metatag.module
index eca7434..0d07d75 100644
--- a/sites/all/modules/metatag/metatag.module
+++ b/sites/all/modules/metatag/metatag.module
@@ -900,6 +900,18 @@ function metatag_page_build(&$page) {
     $page['content']['metatags'] = array();
   }
 
+  // Always add global metatags. These will be ignored if a more specific
+  // override is provided.
+  $cid = "output:global:" . hash('sha256', $GLOBALS['base_url'] . $_SERVER['REQUEST_URI']);
+  if ($cache = cache_get($cid, 'cache_metatag')) {
+    $metatags = $cache->data;
+  }
+  else {
+    $metatags = metatag_metatags_view('global', array());
+    cache_set($cid, $metatags, 'cache_metatag');
+  }
+  $page['content']['metatags']['global'] = $metatags;
+
   // The front page has special consideration.
   if (drupal_is_front_page()) {
     $instance = 'global:frontpage';

Edit: Fixed the patch snippet

DamienMcKenna’s picture

Category: support » feature
FileSize
1.38 KB

This version is a little cleaner - it only loads the meta tags if nothing was found already. I've tested it with metatag_context and the context-provided tags still load correctly, so I think it'll be fine.

torrance123’s picture

Status: Needs review » Reviewed & tested by the community

Great, I've patched our version of Metatags with the patch in comment 7, and all works as expected for us.

DamienMcKenna’s picture

Title: Meta tags module simply does not display tags on views » Always display global meta tags (useful for Views pages, etc)

Updating the title to better describe the change being made.

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
318 bytes

Because this is potentially a performance drain on pages that may not need it, I've added a variable to control it and documented the new variable in the Fine Tuning section of the README.txt file.

DamienMcKenna’s picture

Status: Needs review » Needs work

ARGH. I didn't output the results of "git diff", I output the results of "git status", and I've since reverted the changes.

DamienMcKenna’s picture

FileSize
2.39 KB

Re-recreated the functionality and update to the README.txt file. Also, argh.

DamienMcKenna’s picture

Status: Needs work » Needs review
DamienMcKenna’s picture

Status: Needs review » Fixed

Committed.

DamienMcKenna’s picture

Status: Fixed » Closed (fixed)

Now that Metatag v7.x-1.0-beta5 is out am closing this to keep the issue queue clean.