We're using panels to override the node view, and when that panel is enabled, no Open graph tags are shown. If I disable the panel, all tags show up.
The reason is that hook_node_view never gets called when Panels renders the node.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

blackdog’s picture

Status: Active » Needs review

I did a little research and found this little hook: ctools_render_alter(), which seems to do the trick, so I've added this snippet to opengraph_meta.module:

/**
 * Implements ctools_render_alter().
 *
 * This is done since hook_node_view never gets called if the node is rendered by Ctools.
 */
function opengraph_meta_ctools_render_alter($info, $page, $context) {
  if ($page) {
    foreach ($context['contexts'] AS $ctools_context) {
      if (!empty($ctools_context->data->opengraph_meta)) {
        OpenGraphMeta::instance()->render_data($ctools_context->data, $ctools_context->data->opengraph_meta);
      }
    }
  }
}

Not at all sure this is the preferred way, but seems to do the trick of getting the meta tags out.

blackdog’s picture

Here's a patch that includes the above, slightly improved. I see that Context module uses this hook as well, so I guess it's the preferred way.

Allan Walker’s picture

Hi!

I'm having the same issue with panels, I'm trying to apply this and it doesn't seem to work. Have you encountered any other issues with this? I'm running Panels 7.x-3.0-alpha3 and ctools 7.x-1.0-rc1 if that makes any difference.

hiddentao’s picture

Status: Needs review » Active
ivarvd’s picture

I'm having this problem as well, the patch doesn't work for me.

sam3k’s picture

Not working for me. Placing some prints on the snippet shows that $context['contexts'] is empty. Can anyone tell me what this is and how to make it populate?

jantoine’s picture

Status: Active » Needs review
FileSize
896 bytes

Updated patch against latest 7.x-1.x-dev branch.

rbrownell’s picture

Priority: Normal » Major

Upping the priority of this... Lots of sites use Panels to control the display of nodes because it offers tremendous flexibility and control.

danquah’s picture

Status: Needs review » Reviewed & tested by the community

#7 worked for me. I've tested against both 1.3 and 1.x-dev

Open Graph meta tags is the first result on google when searching for D7 and opengraph, and as panels are very popular it would be really nice to have this patch in as soon as possible. Also, as far as I can see it won't break any backwards compatibility as it is merely introducing a ctools specific hook.

Thanks a lot for the patch!

caspervoogt’s picture

Issue summary: View changes

I couldn't get patch #7 to work, though it applied cleanly. Not sure it matters but I am also running the Metatag module (7.x-1.4), but with the metatag_panels submodule disabled. Running Ctools 7.x-1.4. As a quick fix I added this into my html.tpl.php;

if(!$node){
   print '<meta property="og:image" content="http://www.mysite.com/sites/all/themes/mytheme/images/logo-mydefaultlogo.jpg" />';
  }

.. in the head section. At least this way I can control the default og:image, which was all I really needed to do.

torotil’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Reviewed & tested by the community » Fixed

The new version of opengraph_meta (7.x-2.x) uses metatag to store and render the metatags.

Status: Fixed » Closed (fixed)

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