Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Since I was unable to display my button into the node links, I have looked into the hook_node_view implementation and saw :
if (!empty($locations[$view_mode]) && empty($locations['link'])) {
$node->content['google_plusone'] = array(
'#markup' => theme('google_plusone_button__' . $node->type, $button_settings),
'#weight' => variable_get('google_plusone_weight', -10),
);
}
if (!empty($locations[$view_mode]) && !empty($locations['link'])) {
$node->content['links']['#links']['node_google_plusone_link'] = array(
'title' => theme('google_plusone_button__' . $node->type, $button_settings),
'html' => TRUE,
);
}
The correct implementation for me, since there is no "link" key in $location, is :
if (!empty($locations[$view_mode]) && empty($locations['links'])) {
$node->content['google_plusone'] = array(
'#markup' => theme('google_plusone_button__' . $node->type, $button_settings),
'#weight' => variable_get('google_plusone_weight', -10),
);
}
if (!empty($locations[$view_mode]) && !empty($locations['links'])) {
$node->content['links']['#links']['node_google_plusone_link'] = array(
'title' => theme('google_plusone_button__' . $node->type, $button_settings),
'html' => TRUE,
);
}
Am I wrong or is it a typo ?
Let me know if I can bring a patch.
Thanks!
Comments
Comment #1
corbacho CreditAttribution: corbacho commentedHi there,
Good catch. It's a typo yes, I will fix it in the admin.inc file, when you save the settings should be 'link', not 'links'. This way both 6.x. and 7.x branches have same naming.
It's very small change, no need for patch. Thanks!
http://drupalcode.org/project/google_plusone.git/commit/60f3675
Committed to git, it will be ready to download probably tomorrow (dev branch)
Related to this, is another issue #1230158: Make it possible to display the button in the links section only in full/teaser view (You need Full/Teaser marked AND links area)
Comment #2
alex.druhetOk great ! Thanks