Declaring a display suite layout for a content type causes the meta tag to longer be output to the document head. The meta tag will display fine before any layout is specified for a content type but once you do it won't display again, even if the layout is set to none.

#17 works_with_ds-1115158-17.patch5.87 KBDenes.Szabo
Members fund testing for the Drupal project. Drupal Association Learn more


valthebald’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Assigned: Unassigned » valthebald

I tried to reproduce this and saw that meta fields are displayed both in head and in body.
Then I went to Administration » Structure » Content types »
and selected 'Hidden' in field format and label position for both description and keywords fields.
After that I visited my page and saw it works as expected.
Not the most elegant solution, but worked for me.

kovalchik’s picture

If you navigate to the "Layout for node_type in Default" tab at the bottom of the node display page, and then select any of the layouts from the dropdown the "hidden" option for the field format should disappear. It seems like this is where the problem for me comes in. Display Suite removes the hidden format and tries to print the tag to the content area rather than letting it print to the head.

valthebald’s picture

Can't reproduce this. Some screenshots please?

valthebald’s picture

Status: Active » Postponed (maintainer needs more info)
kovalchik’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

I just tested this again to take some screenshots and the issue appears to have resolved itself. Not sure if it was something with the update from 1.3 -> 1.6 or if I was just drunk or something. Sorry for any confusion if it was the later.

valthebald’s picture

Thanks for your feedback!

pnigro’s picture

Status: Closed (cannot reproduce) » Active


I wasn't sure if I should open a new issue, but I am experiencing the same problem with meta tags quick 7.x-1.9 and display suite 7.x-1.2. I am using the default meta description and meta keyword fields for each of my content types. The only modification I made was changing the label of each of the fields. I did get the meta description and keyword to appear it head temporarily by unchecking 'hide empty regions' in display suite located at admin/structure/types/manage/[content_type]/display. However, after a few refreshes, the meta tags disappear. I then tried rechecking and then unchecking 'hide empty regions' and the tags don't appear any more. If I uninstall display suite, the default meta description and meta keyword fields appear all of the time. I can't seem to figure out what the problem is. Any help would be much appreciated. Great module by the way.


valthebald’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev

I don't use display suite a lot, but in any case, try 2.x-dev snapshot - it has support for all kinds of pages, not only entity-based. 1.x-dev is not developed anymore

pnigro’s picture

Thanks for getting back to me. The 7.x-2.0 beta-1 version does play nice with display suite. The only way I was able to get it to work was by deleting the old keyword and description meta fields from 7.x-1.9 and have 7.x-2.0 beta-1 re-create them by attaching node Keyword and description fields at admin/config/search/metatags_quick. I also had to manually delete meta_description and meta_keyword from the {field_config} and {field_config_instance} tables. The downside of this approach is that I had to re-enter all of my keyword and description fields for each entity. Luckily, I did not have that many. I hope this helps someone else.

Thanks again,

pnigro’s picture

Well, I thought meta tags quick was working with display suite, but I just noticed today that my ubercart product pages are not outputting the meta tags. I performed a fresh install using the following modules:

Chaos tool suite (ctools) 7.x-1.0-beta1
Display suite 7.x-1.2
Entity API 7.x-1.0-beta10
Meta tags quick 7.x-2.0-dev (2011-Jul-28)
Rules 7.x-2.0-beta2
Ubercart 7.x-3.0-beta4
Views 7.x-3.0-rc1

These are the steps I took to reproduce this issue:

1. Install all above modules
2. Select Keyword and Description for all nodes at admin/config/search/metatags_quick
3. Create a basic page and enter keywords and description
4. View source code of node (keyword and description tags display properly)

With Display Suite (No fields in regions)
5. Visit admin/structure/types/manage/page/display and select 'Layout for page in default'
6. Under Select a Layout, choose any layout and Save
7. Visit basic page node and view source (keyword and description tags display properly)

With Display Suite (fields in regions)
8. Revisit admin/structure/types/manage/page/display and add a field to a region and Save
9. Visit basic page node and view source (keyword and description tags are missing)

With Display Suite (No fields in regions)
10. Revisit admin/structure/types/manage/page/display and remove field from region and Save
11. Visit basic page node and view source (keyword and description tags are missing)

Without Display Suite
12. Visit admin/structure/types/manage/page/display and select 'Layout for page in default'
13. Under Select a Layout, choose None and Save
14. Visit basic page node and view source (keyword and description tags display properly)

The really odd thing is that keywords and descriptions on my current install are displaying properly for all display suite enabled content types, except for ubercart product pages. I am not sure how I was able to get mixed results between content types. Any idea what may be causing all of this?


valthebald’s picture

Thanks for such a detailed report, I will dig into this tonight

bleen’s picture


pnigro’s picture

I have been trying to debug this, but I am getting nowhere fast. I thought it may have been an issue of module weight. Currently ds is 1 and metatags_quick is 0. I changed metatags_quick to 2 to check if ds was overriding metatags_quick, but that didn't work.

pnigro’s picture

valthebald, have you had time to look at this? I wish I could help single out the issue, but I am just learning to code.


Denes.Szabo’s picture

This is not a module weight issue. The ds runs through the ds regions and renders it fields, so if a field does not in a ds region will never display out.

I think we have to move the meta field handling to the metatags_quick_page_build(). The path based metafield handling already there, so it is not a big change.

If you insert the meta fields into a ds region the ds will display out them, but if the ds return value not an empty markup just an empty array() the fields will not display. (metatags_quick_field_formatter_view() "Hide element" lines)

pnigro’s picture

Thank you for the explanation Denes.Szabo. I can't believe I didn't try adding the meta description and keyword fields to a region and then setting their labels to hidden. I assumed they would display in the region. The only downside is that the markup for both fields is displayed in the region, which I can live with until a fix is made in code. Thanks again.

Denes.Szabo’s picture

Status: Active » Needs review
5.87 KB

I rewrited this module meta tag inserting part. Now it works with and without ds. I hope it solves issues using this module with panels module too, but I haven't tested it. I tested the node and the path based tags, seems fine.

TODO: Need a little bit work on the comment, taxonomy term and user metatags.

valthebald’s picture

As far as I can see, part of the patch that replaces field_attach_view() is irrelevant (module works the same with or without it). The part that makes the different is the else case:

  elseif ($entity = menu_get_object('node')) {
    $fields = field_info_instances('node', $entity->type);
    foreach ($fields as $field_name => $field_info) {
      // add fields only defined by metatags_quick module
      if ($field_info['widget']['module'] == 'metatags_quick') {
        $items = field_get_items('node', $entity, $field_name);
valthebald’s picture

Status: Needs review » Needs work

However, patch really solves the problem described in the issue. Thing to do: replace node-specific code menu_get_object('node') with generic code, like

  $router_item = menu_get_item();
  // entity object resides in $router_item['page_arguments'] or in $router_item['map']
Denes.Szabo’s picture

You can change but this function type parameter default value is the 'node'… (Maybe works for user entity too without type parameter.)

So, as I described in the code comment: this module for the "node" type entity with this patch works with or without ds - but need additional test for panels module. If you approve the solution offered this patch then we have to add handling code for other entity types this module has support already (user, comments, etc.)

valthebald’s picture

Right, menu_get_object() default value is 'node', and that's the reason it cannot be used for all entities.
Instead, lower-level menu_get_item() should be used

bensnyder’s picture


valthebald’s picture

Status: Needs work » Active

I have reproduced scenarios described in # (thanks to PN!), and after some consideration, it seems this is not really a bug.
The root of the problem is that ds marks all fields (including meta) as hidden.
Solution that works (without any patch):
1. Go to /admin/structure/types/manage/page/display (replace 'page' with content type machine name if necessary)
2. For the meta tag fields, select 'Content' region, '' label location, and default metatags_quick link formatter

This worked for me with various other conditions.
If this helps, I will close this with 'works as designed', but will add a section to the README.txt file

cwithout’s picture

#23 does not apply to the Panels issue (as reported in #1217172: No meta tags on Panels Node or Taxonomy Term pages).

You asked for more detail there and referred to here, but I don't know how to give more detail you except just describing the Panels/Page manager functionality. It doesn't work when you use Panels with the built-in node and taxonomy term pages.

Install Page Manger and Panels. Go to "/admin/structure/pages". Enable "/node/%node" and "/taxonomy/term/%taxonomy_term". For both, create a variant which uses Panels. Use all the defaults and choose any layout you want. Add content (such as node body or term description) . Click "Create variant" then "Update and save". View the taxonomy term pages or node pages source, which has no meta tags even if they were assigned to the node and the taxonomy term.

I tried the patch in #17, but it would not apply to either the 7.x-2.1 release or the current 7.x-2.x-dev.

Denes.Szabo’s picture

#17 will not work for panels, maybe with #19 fixes. I will try tomorrow make the changes, then share the patch.

(DS and maybe panels too use other method to display fields, so simply add a new field will not work.)

valthebald’s picture

#25: did you try #23 scenario? It helped in my case

Denes.Szabo’s picture

I just tried it now. Not helped to my site, there are no meta description in the html.

rvolk’s picture

Here is a working solution:

Feedback would be appreciated!

valthebald’s picture

#28: so, can your solution be incorporated into metatags_quick or metatag, or it works only as a separate module/theme?

Taxoman’s picture

Status: Active » Needs review