I've just spent a day debugging an issue where page titles were being duplicated on panel pages. In the end, it wasn't really a bug in Metatag, Panels or any of this particular site's code (maybe it could be considered a bug in the theme), but it is due to a nuance of the Metatag module. So I still wanted to file an issue here in case someone else struggled with the issue themselves and to advocate consideration for the issue in a distant future release of Metatag.

The Metatag module relies on the $page['content'] region to store information related to Metatags. This site also uses panels heavily, but meanwhile, our theme used a template file for the content region (region--content.tpl.php), which prints out the title and tab links. Normally, the template is never actually used because every page on the site is inserts elements through panels or context instead. We have in fact stripped out all blocks from regions including the "Main page content". Meaning that the page title and tabs were actually rendered through panels as well. The happens when Metatag sets the ['metatags'] key on the $page['content'] render array (see https://www.drupal.org/node/1386320), which is done in metatag_page_build(), creating the 'content' key if it did not exist already. This makes a big assumption that the 'content' region is used in the traditional method, but the approach I describe above approaches a site infrastructure in a different way that runs into issues as a result.

Since I am certain a lot of sites out there use code that works around the $page['content']['metatags'] element and my use case is very specific, which was easily fixed by simply not using the region--content.tpl.php template file, I have no expectation that this will ever be addressed in the 1.x branch of Metatag. However, this might be worth considering for a 2.0 release.

CommentFileSizeAuthor
#3 metatag-n2460791-3.patch5.73 KBdamienmckenna

Comments

damienmckenna’s picture

Title: Metatag forces use of $page['content'] » Allow the page region to be changed
Category: Bug report » Feature request
Status: Postponed » Active

Lets try doing it this way - how about adding a selector to control what page region is used?

bburg’s picture

Wow, fast response. And you alternative seems completely reasonable.

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new5.73 KB

Please give this a spin.

bburg’s picture

Patch works perfectly for my situation! I'd mark as RTBC, but I generally prefer at least a couple of people to agree on that first.

damienmckenna’s picture

Cool, thanks. Out of interest, what region worked for you?

bburg’s picture

Any region that didn't have a corresponding region--[region name].tpl.php file. "postscript fourth" seemed sufficiently out of the way of everything.

damienmckenna’s picture

Status: Needs review » Fixed

Committed. Thanks for the suggestion!

  • DamienMcKenna committed 939eb68 on 7.x-1.x
    Issue #2460791 by DamienMcKenna: Allow the page region used to trigger...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.