How to add "Tweet This" to a node

Ever wanted to add a "Tweet This" to your nodes? Here is how I did it at somoscanada.com. This short tutorial is for people using Drupal.

Open the file node.tpl.php, located under your active theme(sites > all > themes).

At line 96 approximately, add this code(you need to type it!), just before "<?php if ($terms): ?>">. And I am using the Zen theme:

Replace http://somoscanada.com to your domain.

I am using URL Alias(Path module), that's why you see "echo $node->path", it prints the node alias. If you are not using the Path module, then replace that with "php print $node->nid", it prints node/ID.

Last, upload the file node.tpl.php to your server. If you do not see that changes, go to "Site Information > Performance >", empty your cached data.

Comments

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options