In Drupal 7, it's possible for the Content theme region to be empty (e.g., if you have dragged the main page content block elsewhere via the Blocks UI). If your site is configured that way, it turns out metatags won't be added to the page.
The attached patch fixes it. I tested that with this patch applied, the bugs from #1281570: PHP notice when enable or disable links clicked in overlay (and redirect problem) (which added this code in the first place) still don't seem to reoccur.
| Comment | File | Size | Author |
|---|---|---|---|
| metatag-no-main-page-content.patch | 629 bytes | David_Rothstein |
Comments
Comment #1
David_Rothstein commentedOne side effect of this patch worth noting is that because the Meta Tags module will now populate $page['content'] even when it was previously empty, sites which did not have any blocks or other content in the main page region might still get wrapper divs and such appearing for that region in the HTML, once this module is turned on. This could have unexpected effects on the appearance of the site.
However, that's really more a general Drupal core issue anyway (see #953034: [meta] Themes improperly check renderable arrays when determining visibility)...
Comment #2
devuo commented+1 for the patch. I don't think that is as problematic as you make it sound, and it's certainly a preferable solution than not working at all (for those using exclusively panels)
Comment #3
jchatard commentedThanks, worked for me.
Comment #4
damienmckennaRather than hacking away trying to get this working, and ultimately building work-arounds for an existing work-around in Metatag, the output logic has been re-written thanks to jenlampton and I'm hoping it works better now. Please try the latest -dev release and please let me know if it works as-is, and re-open the issue if it's still not working.
That said, please be aware that right now it doesn't let you override tags for taxonomy term pages due to a core bug, please keep an eye on #1700160: Support taxonomy term pages until taxonomy supports hook_entity_view() for further updates.
Comment #5
damienmckennaRelated and honestly a higher priority: #1708718: Ensure Meta tags work OOTB with Drupal core
I'm going to fix that and then see how to resolve this issue.
Comment #6
anouHello,
I must say that to work on front-page (and surely other pages), you must print :
<?php print render($page['content']); ?>otherwise no meta from metatag will print in head...
And for your module.
Comment #7
damienmckennaThis was fixed by #1363476: Panels integration - ensure meta tags work OOTB on entity pages.