CVS edit link for willsteinmetz

The module that I created enables Drupal site administrators to add a Facebook Share button to selected nodes in their website(s). The motivation behind creating this module was the TweetMeme module that allowed users to retweet about a given website node. After searching through the modules directory on Drupal.org, I was unable to find a module that offered similar functionality as the TweetMeme module but for Facebook share.

The Facebook Share module gives Drupal site administrators the ability to choose settings for which nodes to display the button on, whether to display on the teaser, full view, or both, what button type to be displayed, and what share text to be displayed on the button.

I currently have a working version of the module in use on my project website http://hot4headers.com.

I intend to keep up with this module and apply bug fixes and updates as necessary. I will also keep on top of changes in the Facebook API that cause the underlying code for the Facebook Share button to need to be changed.

It is my hope that in the future I will also be able to contribute other modules to the Drupal community as well as the Facebook Share module.

Comments

willsteinmetz’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new2.18 KB
avpaderno’s picture

Status: Needs review » Needs work
Issue tags: +Module review

Hello, and thanks for applying for a CVS account. I am adding the review tags, and some volunteers will review your code, pointing out what needs to be changed.

As per http://drupal.org/cvs-application/requirements, the motivation message should be expanded to contain more details about the features of the proposed module, and it should include also a comparison with the existing solutions.

willsteinmetz’s picture

Status: Needs work » Needs review

The Facebook Share module enables Drupal site administrators to add a Facebook Share button to selected content type nodes in their website(s). The motivation behind this module was the TweetMeme module which allows users to retweet about a given website node.

The Facebook Share module gives Drupal site administrators the ability to choose the following settings:

  • determine content types to display the Facebook Share button on
  • whether to display the Facebook Share button on the teaser, full view, or both
  • what button type to be displayed (box_count, button_count, button, icon_link, or icon)
  • what share text to be displayed on the button (Share by default)

When the Facebook Share module is enabled for a content type, website viewers can click the Facebook Share button to share a link to that node in their Facebook stream.

Benefits of using the Facebook Share module instead of modules that allow users to select from a variety of social networks (ex: Add to Any Share/Bookmark Button and Service links):

  • A count of the number of times that a link been shared on Facebook
  • The administrator can keep a stronger hold on what social networks the content of their websites is shared on
  • The type of icon/button that is used can be selected where other modules only allow a small icon for the variety of social networks that they support

A working version of the module can be seen at http://hot4headers.com.

zzolo’s picture

Status: Needs review » Needs work

I don't necessarily think you should be using the FB Drupal module, but you have not mentioned this at all. Can you describe the difference between your module and the FB module. http://drupal.org/project/fb

willsteinmetz’s picture

Status: Needs work » Needs review

Updated motivation message per zzolo's comment about the FB Drupal module:

The Facebook Share module enables Drupal site administrators to add a Facebook Share button to selected content type nodes in their website(s). The motivation behind this module was the TweetMeme module which allows users to retweet about a given website node.

The Facebook Share module gives Drupal site administrators the ability to choose the following settings:

  • determine content types to display the Facebook Share button on
  • whether to display the Facebook Share button on the teaser, full view, or both
  • what button type to be displayed (box_count, button_count, button, icon_link, or icon)
  • what share text to be displayed on the button (Share by default)

When the Facebook Share module is enabled for a content type, website viewers can click the Facebook Share button to share a link to that node in their Facebook stream.

Benefits of using the Facebook Share module instead of modules that allow users to select from a variety of social networks (ex: Add to Any Share/Bookmark Button, Service links, and FB Drupal):

  • A count of the number of times that a link been shared on Facebook
  • The administrator can keep a stronger hold on what social networks the content of their websites is shared on
  • The type of icon/button that is used can be selected where other modules only allow a small icon for the variety of social networks that they support
  • While the FB Drupal module allows for publishing to a Facebook user's activity stream, the FB Drupal module is a platform for developing Facebook applications that are driven by Drupal and a Facebook application must be built and added by Facebook users in order to have information pushed to their activity stream. Using the Facebook Share module, there is no need to for users to add and authorize an application on Facebook, they simply need to be logged into Facebook.

A working version of the module can be seen at http://hot4headers.com.

zzolo’s picture

Some thoughts:

  1. All code files should have @file docblocks.
  2.     // Make sure the user has access to use TweetMeme.
    

    :)

  3. You are not deleting the "facebookshare_text" variable in the uninstall hook.
  4.   $form['facebookshare_sizes_list'] = array(
        '#type' => 'markup',
        '#value' => '<strong>Share button types:</strong><div style="clear: both;">box_count: ' .
          '<a name="fb_share" type="box_count"' .
          'share_url="http://www.facebook.com/facebook-widgets/share.php"></a>' .
          '<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" ' .
          'type="text/javascript"></script></div>' .
          '<div style="clear: both;">button_count: <a name="fb_share" type="button_count"' .
          'share_url="http://www.facebook.com/facebook-widgets/share.php"></a>' .
          '<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" ' .
          'type="text/javascript"></script></div>' .
          '<div style="clear: both;">button: <a name="fb_share" type="button"' .
          'share_url="http://www.facebook.com/facebook-widgets/share.php"></a>' .
          '<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" ' .
          'type="text/javascript"></script></div>' .
          '<div style="clear: both;">icon_link: <a name="fb_share" type="icon_link"' .
          'share_url="http://www.facebook.com/facebook-widgets/share.php"></a>' .
          '<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" ' .
          'type="text/javascript"></script></div>' .
          '<div style="clear: both;">icon: <a name="fb_share" type="icon"' .
          'share_url="http://www.facebook.com/facebook-widgets/share.php"></a>' .
          '<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" ' .
          'type="text/javascript"></script></div>',
      );
    

    You should figure out a way to utilize your theme function to display these as someone could override the theme and this would no longer be representative of the buttons. Also, having all that output not in a theme is just kind of icky.

  5. <div style="float: right; clear: right;">
    

    You should be using CSS for this. This is very difficult, if not impossible to override.

  6.     // Check in the teaser view.
        if ($teaser && !empty($location['teasers'])) {
          $node->content['facebookshare'] = array(
            '#value' => theme('facebookshare', $url),
            '#weight' => -10,
          );
        }
        // Check in the full view.
        else if(!$teaser && !empty($location['content'])) {
          $node->content['facebookshare'] = array(
            '#value' => theme('facebookshare', $url),
            '#weight' => -10,
          );
        }
    

    Could be better written as:

    
        // Check what view and if allowed
        if (($teaser && !empty($location['teasers'])) || (!$teaser && !empty($location['content']))) {
          $node->content['facebookshare'] = array(
            '#value' => theme('facebookshare', $url),
            '#weight' => -10,
          );
        }
    

Overall, pretty minor changes. This is real close. Good work.

zzolo’s picture

Status: Needs review » Needs work
willsteinmetz’s picture

Status: Needs work » Needs review
StatusFileSize
new2.38 KB

Code has been updated/fixed per zzolo's comment above.

Thanks, zzolo!

zzolo’s picture

Status: Needs review » Needs work

Getting there:

  1. /**
     * Implements hook_init()
     */
    function facebookshare_init() {
      drupal_add_css(drupal_get_path('module', 'facebookshare') . '/facebookshare.css');
    }
    

    You should not be putting CSS in an init hook unless it really needs to be on every page. You should add your CSS before you call your theme function in the nodeapi hook.

  2.   $form['facebookshare_sizes_list'] = array(
        '#type' => 'markup',
        '#value' => '<strong>Share button types:</strong><div style="clear: both;">box_count: ' .
          theme(
            'facebookshare_button',
            'http://www.facebook.com/facebook-widgets/share.php',
            'box_count',
            t('Share')
          ) .
          '</div>' .
          '<div style="clear: both;">button_count: ' .
          theme(
            'facebookshare_button',
            'http://www.facebook.com/facebook-widgets/share.php',
            'button_count',
            t('Share')
          ) .
          '</div>' .
          '<div style="clear: both;">button: ' .
          theme(
            'facebookshare_button',
            'http://www.facebook.com/facebook-widgets/share.php',
            'button',
            t('Share')
          ) .
          '</div>' .
          '<div style="clear: both;">icon_link: ' .
          theme(
            'facebookshare_button',
            'http://www.facebook.com/facebook-widgets/share.php',
            'icon_link',
            t('Share')
          ) .
          '</div>' .
          '<div style="clear: both;">icon: ' .
          theme(
            'facebookshare_button',
            'http://www.facebook.com/facebook-widgets/share.php',
            'icon',
            t('Share')
          ) .
          '</div>',
      );
    

    You are not using the t() when needed. Also, I was hoping you would use a loop or something here. You could define a short array then loop through it and save lots of code and effort (not a huge deal). To really be up to standard, you should create a theme function for this, and all you would have to do is send it your array of types.

  3.   $form['facebookshare_size'] = array(
        '#type' => 'select',
        '#required' => TRUE,
        '#options' => array(
          'box_count' => 'box_count',
          'button_count' => 'button_count',
          'button' => 'button',
          'icon_link' => 'icon_link',
          'icon' => 'icon'
        ),
        '#default_value' => variable_get('facebookshare_size', ''),
      );
    

    You don't have a title. Not necessary, but a suggestion would be to actually display each example next to the selection (this would require using a radio list).

  4. Your CSS files needs a file docblock and $Id$

So close!

willsteinmetz’s picture

Status: Needs work » Needs review
StatusFileSize
new2.45 KB

Code has been updated/fixed based on zzolo's last comment.

The display of the button sizes on the configuration has been changed to radio buttons instead of a display followed by a drop-down which helps the flow of the page and looks a lot better than it did before.

The CSS file call has also been moved to the hook_node_api() function implementation so that it's not included on pages that the Facebook Share button will be displayed on.

Also, are there any other suggested changes to the last update I made to the motivation message above? (comment #5 above)

P.S. Thanks for all of the great suggestions, zzolo

zzolo’s picture

Status: Needs review » Needs work

Your updated manifesto for the module is much better and totally acceptable.

  1. .form-radios .form-item {
    	width: 130px;
    	float: left;
    }
    

    This CSS declaration will alter how all radios will look. You should use the element ID that gets put on the wrapper of the rendered element; using Firebug will make it really easy to see the HTML. Technically you should have a separate CSS file for your admin page since it is only needed on one page, but I don't think thats necessary here.

  2. I think your CSS file is using tabs instead of spaces.
  3.   // required in order to shift next form item below properly
      $form['spacer'] = array(
        '#type' => 'markup',
        '#value' => '<div class="facebookshare-spacer">&nbsp;</div>',
      );
    

    You should be able to target just that element and use the clear you need. You could also (though not suggested) use a "clear-block" class on the "facebookshare_size" element with attributes which should clear it out.

So close. The first one is important while the second two are not as necessary. I bet next one around will be it.

willsteinmetz’s picture

Status: Needs work » Needs review
StatusFileSize
new2.42 KB

I have made the updates to the code per zzolo's comment above.

The CSS for the admin settings form has been added to its own CSS file that is only attached when the admin settings form is loaded. The spacer <div /> has also been removed from the form. Also, not sure how the tabs got in there so they've been replaced by spaces like they should be.

Hopefully this round did it.

zzolo’s picture

Status: Needs review » Reviewed & tested by the community

That's one good looking module! I would say this is ready to go. Good work.

avpaderno’s picture

Status: Reviewed & tested by the community » Fixed

Thank you for your contribution! I am going to update your account.
These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the dedicated reviewers as well.

Status: Fixed » Closed (fixed)
Issue tags: -Module review

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

avpaderno’s picture

Component: Miscellaneous » new project application
Assigned: Unassigned » avpaderno
Issue summary: View changes