I post it here as I think it is a Panels issue.

I got a D7 website whose pages are rendered through Panels, actually Node, Taxonomy Term and User templates. I haven't added node:content pane to the panels as the main content. Instead I put a collection of views in the different regions of my panel layout.

I installed Remove Generator and set up Meta tags, OpenGraph Meta tags and Schema.org for my node types. But it seems there are no meta nor Schema.org information on pages displayed through Panels. Nor the Generator Meta is removed in them.

I'm sure it is up to Panels as a collection of views and panes since the problem disappears whenever I disable the Panel template or I put the node:content pane in it.

Files: 
CommentFileSizeAuthor
#11 1485074_11_panels_tpl_attributes.patch6.8 KBscor
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]
#10 1485074_10_panels_tpl_attributes.patch5.97 KBscor
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]
#5 panels-twocol-bricks.tpl_.php_.txt2.69 KBminsky

Comments

scor’s picture

The schema.org isn't a requirement to reproduce this bug since it leverages the core RDF API and in particular the RDFa markup that @cesareaugusto was expecting to find in its pages. In other words, simply installing Drupal 7 (standard profile) is enough to have some RDFa markup in the regular node pages (search for the @property attribute for example), which is missing from the output @cesareaugusto is talking about.

merlinofchaos’s picture

I believe the issue is that these things produce their output via hook_node_view -- in order for this to run you must add the 'node: content' pane.

This is a known issue, but a proper solution hasn't arisen yet. One potential solution is to run this using hook_ctools_render_alter()

cesareaugusto’s picture

I believe the issue is that these things produce their output via hook_node_view -- in order for this to run you must add the 'node: content' pane.

Using the node: content pane I couldn't spread fields into the different regions of my custom layout. How could I reproduce this behaviour with node: content pane.

This is a known issue, but a proper solution hasn't arisen yet. One potential solution is to run this using hook_ctools_render_alter()

Do you think it will be fixed in the short period?

farald’s picture

Have anyone successfully fixed this using hook_ctools_render_alter() ?

minsky’s picture

StatusFileSize
new2.69 KB

You can workaround it by overriding your layout's template file, which is found in modules/panels/plugins/layouts . Although not documented, you can use the $variables variable inside. See the attached file for 2 col brick layout example.
Note that I didn't test this thoroughly, but my feeling is that this is the way to go

LTech’s picture

I am trying to show microtags on my pages which are built using views and panels.
Which template file would I need to override to add the following ?

itemprop="dateCreated" class="field-content">2012
Do I override a panels or views tpl.php file. And how do I label it?
Thanks

LTech’s picture

I've already created a panels page using the interface. How do I wrap the entire code in a tag and close the tag AFTER ALL the panes?
Is using plugins/layouts/ the way to go?
Thanks

umar.adil’s picture

@minsky The overriding you suggested does not serve the full purpose. No doubt this added some properties on the top of the content. I am using the schema properties on a content type recipe. I have override my template file as

<div class="column column-main" id="content" about="<?php print $variables['display']->context['argument_entity_id:node_1']->data->type.'/'.$variables['display']->context['argument_entity_id:node_1']->data->title ;?>" typeof="<?php print implode($variables['display']->context['argument_entity_id:node_1']->data->rdf_mapping['rdftype'], " ");?>">
<span rel="schema:url" resource="<?php print $variables['display']->context['argument_entity_id:node_1']->data->type.'/'.$variables['display']->context['argument_entity_id:node_1']->data->title ;?>" class="rdf-meta"></span>
<span property="schema:name" content="<?php print $variables['display']->context['argument_entity_id:node_1']->data->title ;?>" class="rdf-meta"></span>
    <?php print $content['main']; ?>
  </div>

This outputs the schema properties like typeof and url, but the schema property is not added on other fields like

  1. Preparation time
  2. Cooking time
  3. Yields
  4. ingredients
  5. Cooking directions
jemond’s picture

Issue summary:View changes

Here is what I used for a fix, if it's helpful to others:

function hook_preprocess_panels_pane(&$vars) {
  $pane = $vars['pane'];
  $display = $vars['display'];

  if ($pane->type != 'token' || strpos($pane->subtype, 'node') === FALSE) {
    return;
  }

  $node = $display->context[$pane->configuration['context']]->data;
  // The field name is hiding in the panel subtype.
  list($entity_type, $field_name) = explode(':', $pane->subtype);
  $field_name = str_replace('-', '_', $field_name);

  // If we have no schema.org data to add, abort.
  if (!isset($node->rdf_mapping[$field_name])) {
    return;
  }

  // It's finally time to add the schema.org data!
  $attributes = rdf_rdfa_attributes($node->rdf_mapping[$field_name]);
  $vars['attributes_array'] += $attributes;
}

scor’s picture

Version:7.x-3.0» 7.x-3.x-dev
Status:Active» Needs review
Issue tags:+RDF in panels
StatusFileSize
new5.97 KB
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]

I committed a fix for this in the RDFa module which requires a slight modification of Panels templates, see patch attached. This patch merely aligns the layout tpls to correspond to those of core, but outputting $attributes in the top level HTML element, exactly like node.tpl.php.

Together with https://www.drupal.org/project/rdfa, this patch takes care of the approach described in #5, #7 and #8. It only works for nodes at the moment, but I plan to add support for user, taxonomy term etc if the feedback is good.

To try this patch:
- Make sure you have set up RDF mappings for your content type, for example using https://drupal.org/project/schemaorg
- install the latest version of https://www.drupal.org/project/rdfa
- apply this patch to your version of Panels

To verify that this patch is working well, you can see if you have this kind of markup at the top of your layout:

<?php
<div class="panel-2col-stacked clearfix panel-display" typeof="schema:Recipe" resource="/node/2">
?>

There should also be this new HTML element near the bottom of your Panels layout:

<?php
<span content="title of my node" property="dc:title" class="rdf-meta"></span>
?>

Positive and negative feedback are both appreciated.

Regarding #8 specifically:

This outputs the schema properties like typeof and url, but the schema property is not added on other fields like

I tried the recipe module with my patch, and all the fields had the correct markup, including the yield/cooking time block. Note that I selected the recipe fields one by one in the Panels UI:
- node:recipe description
- node:recipe ingredients
- Recipe summary (located in the Miscellaneous tab of the "add content" popup)

scor’s picture

StatusFileSize
new6.8 KB
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]

I forgot to cover the case of the flexible layout. Here it is now in this patch.

DamienMcKenna’s picture

First off, Metatag has had a work-around for this for the past two-or-so years.

Secondly, it should no longer be an issue due to #1760384: Update node_view.inc to execute the normal Drupal hooks and related changes in CTools.

Please retest whether this is still broken with CTools 3.5 or a current dev snapshot.

ITWest-jg’s picture

What do you mean CTools 3.5? CTools is currently on 7.x-1.7 ...

DamienMcKenna’s picture

Sorry, I was mixed up between Panels and CTools, please test with CTools 7.x-1.7.

JayShoe’s picture

I tried this with ctools-7.x-1.7 and this issue still exists. I tried this with ctools-7.x-1.x-dev and it seemed to resolve the issue. So once the latest version of ctools is released (7.x-1.7+18-dev 2015-May-16 version, at the time of this writing) this issue should be resolved. Until then, no luck unless you want to run the dev release.

scor’s picture

According to the git history, the fix #1760384: Update node_view.inc to execute the normal Drupal hooks was first released in ctools 7.x-1.6 so it should be in 1.7 too. Are you sure it's not working in 1.7 but working in the dev release? How are you testing this?

JayShoe’s picture

I'm sorry. I was mistaken. I was able to get this to work with 1.7. But the results weren't very good so they weren't being parsed correctly by the Structured Data Testing Tool. I wound up using the microdata module with much better success.