Add a “tweetthis” link to any page
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:
- Login to your manager interface Go to Elements->Manage Elements->Snippets->New Snippet.
- 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
- Save your snippet
-
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.
- Example Snippet Call: [!tweetthis?&name=`Shopping_CartIt`!] Save your template.
- If desired, edit your CSS to style the link.
- 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.