I am trying to figure out how to add a facebook like button right after the title? I want it to be the title --- And then a few spaces away a small like button. I can't figure out how to do this since I can't change the title in the node.tpl.php...

This is the code I want to add, but don't know where...

<?php $url = url($node_url, array('absolute' => TRUE)) ?>
<fb:like layout="button_count" href="<?php print $url; ?>"></fb:like>

Comments

maddentim’s picture

not sure this module is the place to accomplish your goal. Usually, the title is defined in the page.tpl.php file, not node.tpl.php.

sammyman’s picture

Yes, but for some reason I can't place the facebook like button after the title, and I use automatic nodetitles for the titles of each node on my site so I thought the problem was correlated to this module.

maddentim’s picture

Component: Code » Miscellaneous

Since you are using auto_nodetitle, I assume that your title is not blank. What theme are you using? Can you post your page.tpl.php and where you have attempted to place the like button. My understanding is that auto_nodetitle module is not involved with the rendering of an existing node. Just in the creating or editing of a node. This issue probably should be in the queue of your theme, not in auto_nodetitle.

maddentim’s picture

Component: Miscellaneous » Code

didn't mean to switch it to misc from code...

NancyDru’s picture

In #804112: Open graph and I Like I posted a little module (an add-on to the Drupal for Facebook package) that formats the Like button as part of the node content ($node->content array) and allows one to adjust its weight. For example, setting the weight to -10 makes it float to the very top, as in right under the title.

polishyourimage’s picture

fb_example.module has a hook for placing it at the top of $content - just change FLASE to TRUE:

<?php
  // Another way to add like button, as part of a node.
  if ($op == 'view' && variable_get('fb_example_nodeapi_add_like', FALSE)) {
    $url = fb_scrub_urls(url('node/' . $node->nid, array('absolute' => TRUE)));
    $node->content['dff_like'] = array(
      '#value' => "<fb:like href={$url}></fb:like>",
      '#type' => 'markup',
      '#prefix' => '<div class="dff_like_wrapper">',
      '#suffix' => '</div>',
    );
  }
}
?>

You can also add it directly to node.tpl.php (below example is Zen - it's added just after css class .meta .submitted):

<span class="submitted">
          <?php
            print t('Submitted by !username on !datetime',
              array('!username' => $name, '!datetime' => $date));
          ?>
          <fb:like href=<?php $curr_url = check_plain("http://" .$_SERVER['HTTP_HOST'] .$node_url); echo $curr_url; ?>></fb:like>
          </span>
gaurav.kapoor’s picture

Issue summary: View changes
Status: Active » Closed (outdated)