Textpattern tips, tutorials and code snippets

Add a Twitter share link that validates

I found that my page wouldn’t validate at W3C Validator because of a Twitter button.

Here is a very easy way to make a Twitter button that does validate in Textpattern.

Make a form and paste in:

<p><a href="http://twitter.com/share?url=<txp:permlink />" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></p>

Then put:

<txp:output_form form="twitter" />

Wherever you want the button to appear.

The button opens a Tweet window with the page title and url already in place.

5 Comments Comment feed

  • Timid
  • 8 December 2011

Great! Thx!

It might worth to implement Twitter embedding API, too — it requires URL quoting only for a usen, like in http://savas.palubinskas.lt (currently on top of the page). I have made it following http://blog.posterous.com/introducing-embeddable-tweets (and an example on http://www.brownday.me/embeddable-tweets-now-on-posterous).

  • Mark
  • 18 December 2011

All my tweet buttons show they’ve been tweeted twice. Shouldn’t they start with a zero?

Nice tip, thanks! I just implemented it.

Hey! This is kind of off topic but I need some advice from an established
blog. Is it very hard to set up your own blog? I’m not very techincal but I can figure things out pretty fast. I’m thinking about setting up my own but I’m not sure where to start. Do you have any tips or suggestions? Appreciate it

Add a comment

Use Textile help to style your comments