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.

CommentFileSizeAuthor
metatag-no-main-page-content.patch629 bytesDavid_Rothstein

Comments

David_Rothstein’s picture

One 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)...

devuo’s picture

+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)

jchatard’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, worked for me.

damienmckenna’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

Rather 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.

damienmckenna’s picture

Related 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.

anou’s picture

Hello,
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.

damienmckenna’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)