Data Center Hub

Internet Data Center and Hosting News and Views

Add a “tweetthis” link to any page

Filed under: SEO — Bill Laakkonen at 11:37 am on Tuesday, November 3, 2009

Dave Child at AddedBytes.com created a really cool snippet for Modx 0.9.6.3 called “tweetthis” The tweetthis snippet will return a link to twitter for the user to tweet the current page. The URL is sent through TinyURL automagically and TinyURLs are cached indefinitely to assets/cache/tweetthis.txt. The Link is given the class “tweetthis” so you may apply some styling to it. Here is a link to download tweethis. It also works on Modx 1.0 (for me, at least).

Here’s how to add it to your Modx site:

  1. Login to your manager interface Go to Elements->Manage Elements->Snippets->New Snippet.
  2. Give your new snippet a name of “tweetthis” and copy and paste the text of the snippet file into the snippet code form- don’t forget to keep the PHP open and close tags, choose a category under “Properties” and tick off the “Lock snippet” box
  3. Save your snippet
  4. Open your desired template (e.g blog or default) and add a call to the snippet with your optional parameters.

    &name=`@Shopping_CartIt` Optionally use your Twitter ID by prefixing your ID with an @.

    &text=`Tweet This!` Optional label Text for the link. “Tweet This!” is the default text.

    &id=`5` Optional Document ID. If not specified it defaults to the current document.

  5. Example Snippet Call: [!tweetthis?&name=`Shopping_CartIt`!] Save your template.
  6. If desired, edit your CSS to style the link.
  7. Test your page, apply to additional templates.

Here is a site with the TweetThis snippet installed- try it out. If you’re not using ModX, check it out. I’ve built a dozen sites with it over the last few years and it is a powerful platform for SEO and content management.

No Comments

No comments yet.

RSS feed for comments on this post.