'FB Like Button', 'description' => 'Control which content types the "like" button should appear on.', 'page callback' => 'drupal_get_form', 'page arguments' => array('fblikebutton_admin_settings'), 'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM, 'file' => 'fblikebutton.admin.inc', ); return $items; } /** * Implementation of hook_nodeapi(). * @todo * Add more config options for like button (size, etc). */ function fblikebutton_nodeapi(&$node, $op, $teaser, $page) { global $user; global $base_url; $likebase = $base_url . '/'; $likepath = drupal_get_path_alias($_GET['q']); $webpage_to_like = $likebase . $likepath; switch ($op) { case 'view': // Set which node types users can "like". $types_to_like = variable_get('fblikebutton_node_types', array('page')); $show_faces = variable_get('fblikebutton_show_faces', 'true'); // Facebook is doing away with FBML, so we use the iframe plugin option instead. $likebutton = ''; // Keep the fblikebutton button out of search results, etc. if (!$page) { break; } // Do not add the like button to any of the unchecked node types. if (!in_array($node->type, $types_to_like, TRUE)) { break; } // Set permissions, and keep the button out of teasers. Otherwise, there // would be 50 "like" buttons on the front page of some sites... Not good. if (!$teaser && user_access('users may access Like button')) { $node->content['fblikebutton_button'] = array( '#value' => $likebutton, '#weight' => 100, ); } break; } } /** * Implementation of hook_perm(). */ function fblikebutton_perm() { return array('users may access Like button'); }