The tweet button is output regardless of settings

Files: 
CommentFileSizeAuthor
#7 show_button_in_node_teasser-1139470-7.patch887 byteswolmi

Comments

I tried to create a patch but couldn't navigate through your git repo succesfully.. the following changes to tweetbutton_node_view fix the issue:

<?php
/**
* Implementation of hook_node_view()
*/
function tweetbutton_node_view($node, $view_mode) {
   
$types = variable_get('tweetbutton_node_types', array());
   
$full = ($view_mode == 'full') ? TRUE : FALSE;
   
$show = ( ! empty($types[$node->type]) &&
         
$full && user_access('access tweetbutton'));
  if (
$show) {
   
drupal_add_js('http://platform.twitter.com/widgets.js');
   
drupal_add_css(drupal_get_path('module', 'tweetbutton').'/tweetbutton.css');
   
// @todo: Add support for token replacements
   
$token_replacements = array(
     
'!title'        => $node->title,
     
'!author_name'  => $node->name,
     
'!node_type'    => $node->type,
     
'!node_url'     => url('node/'.$node->nid, array('absolute' => TRUE)),
    );
     
$node->content['tweetbutton'] = array(
     
'#tokens'   => $token_replacements,
     
'#weight'   => variable_get('tweetbutton_node_weight', -5),
     
'#theme'    => 'tweetbutton_display',
    );
  }
}
?>

Status:Active» Needs review

hi - can you clarify if this issues is about the 'Full View' versus "Teasers' settings - or is that when setting for node types here admin/config/tweetbutton/node it seems to me that regardless of setting Tweet to be unchecked for several content types, new content of that type ends up with a Tweet button when I don't expect it. Happy to make a new ticket if yours is 'teaser and node' settings rather than 'teaser or node' settings ;-)

Hi Peter.. I can't remember to be honest. :)

From memory, the problem that my change fixed was to only display the tweet button on node types it was set for, previously it output on all node types I think.

i think i agree - but i hoped it may also resolve fact that the tweet button is coming through on Teasers - whereas Facebook like doesn't - but guess I will trawl the issues queues - though may both are working as intended - they just have different starting points

sub

Subscribing

StatusFileSize
new887 bytes

The solution proposed on #1 is not exact.

I posted this patch on http://drupal.org/node/1272424 but I think is better to post here.

the result will look like this:

<?php
/**
* Implementation of hook_node_view()
*/
function tweetbutton_node_view($node, $view_mode) {
$type = variable_get('tweetbutton_node_types', array('article' => 'article'));
  if(isset(
$type[$node->type]) && $type[$node->type] !== 0
   
&& in_array($view_mode, variable_get('tweetbutton_node_location', array('full')))
    &&
user_access('access tweetbutton')) {
   
drupal_add_js('http://platform.twitter.com/widgets.js');
   
drupal_add_css(drupal_get_path('module', 'tweetbutton').'/tweetbutton.css');
   
// @todo: Add support for token replacements
   
$token_replacements = array(
     
'!title'        => $node->title,
     
'!author_name'  => $node->name,
     
'!node_type'    => $node->type,
     
'!node_url'     => url('node/'.$node->nid, array('absolute' => TRUE)),
    );
         
$node->content['tweetbutton'] = array(
     
'#tokens'   => $token_replacements,
     
'#weight'   => variable_get('tweetbutton_node_weight', -5),
     
'#theme'    => 'tweetbutton_display',
    );
  }
}
?>

Status:Needs review» Fixed

I have tested it for the latest 7.x-1.x and it seems to be fixed.
reopen this issue if this problem persists

Status:Fixed» Closed (fixed)

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