Skip to content

Instantly share code, notes, and snippets.

@SupermanScott
Created April 9, 2010 18:22
Show Gist options
  • Save SupermanScott/361432 to your computer and use it in GitHub Desktop.
Save SupermanScott/361432 to your computer and use it in GitHub Desktop.
diff --git a/html/sites/all/modules/custom/share_post/share_post.module b/html/sites/all/modules/custom/share_post/share_post.module
index 1d89140..853abd2 100644
--- a/html/sites/all/modules/custom/share_post/share_post.module
+++ b/html/sites/all/modules/custom/share_post/share_post.module
@@ -68,8 +68,18 @@ function share_post_block($op = 'list', $delta = 0, $edit = array()) {
case 'view':
$block = array();
if ($delta == 'share_post') {
- $block['subject'] = t('Social links');
- $block['content'] = _share_posts();
+ $node = menu_get_object();
+
+ // Check the page arguments to make sure we are Viewing the node.
+ $router_item = menu_get_item();
+ if (count($router_item['page_arguments']) > 1) {
+ $node = FALSE;
+ }
+
+ if (!empty($node)) {
+ $block['subject'] = t('Social links');
+ $block['content'] = _share_posts($node);
+ }
}
return $block;
break;
@@ -81,18 +91,12 @@ function share_post_block($op = 'list', $delta = 0, $edit = array()) {
*
* @return unknown_type
*/
-function _share_posts() {
- $args = arg();
-
- if ($args[0] == 'node' && is_numeric($args[1]) && !$args[2]) {
- $node = node_load($args[1]);
-
- $theme_hooks = array(
- 'share_post__' . $node->nid,
- 'share_post__' . $node->type,
- 'share_post'
- );
+function _share_posts($node) {
+ $theme_hooks = array(
+ 'share_post__' . $node->nid,
+ 'share_post__' . $node->type,
+ 'share_post'
+ );
- return theme($theme_hooks, $node);
- }
+ return theme($theme_hooks, $node);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment