Tweet Button

By bcammo bcammo

Description

This snippet will add the official Twitter tweet button to your wikidot page. This allows visitors to tweet about the page they are on by displaying a popup window, meaning they don't need to leave your site.

Attributes

The snippet uses the following attributes, most of which are required for the button to work properly.
Attribute Required Allowed values Default value Description
url yes any valid URL, including %%link%% The URL of the page you want to share.
text yes any text The text that people will include in their Tweet when they share from your website.
via yes any twitter username The username you want @-mentioned in the tweet (probably your own).
count yes vertical, horizontal, none Controls the display of the tweet count.
align no left, right, center left Sets the horizontal positioning of the button.

Please note: the float variable has been changed to align, as it better describes the function of the property. Please adjust your includes accordingly.

Code

You can add the tweet button to your page with the following code:

[[include :snippets:tweet-button
|url=http://example.com
|text=Check out this awesome page on @wikidot
|via=twitter-username
|count=vertical
]]

You can also use the button in a live template. Such a use might use the code below.
[[include :snippets:tweet-button
|url=%%link%%
|text=%%title%%
|via=twitter-username
|count=horizontal
]]

In action

See the button below for a real-life working solution. Go on, you know you want to press that button…

[フレーム]


Thanks to tsangk for this great snippet: conditional-blocks


text above inserted with:

[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]



Other snippets posted by bcammo

Chatbox - 26 Mar 2012 11:07
Google +1 Button - 19 Mar 2012 19:40


Rate this solution

If you think this solution is useful — rate it up!

rating: +13
page 1 of 21
Making tweet-button work on a secure wiki
janbmgo janbmgo 12 Dec 2018 21:32

Hi, I am using this snippet a lot.
When enabling SSL encryption it doesn't work anymore though as:
- the link to the twitter share button uses http://twitter.com/share &
- <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>

Just using
https://twitter.com/share & <script type="text/javascript" src="https://platform.twitter.com/widgets.js"></script>
instead makes it work again.

Could you modify the snippet in this way? So I don't have to define a new snippet and change it across my wikis?

Thanks a lot in advance!


Jan Goossenaerts
@collaboratewiki

by janbmgo janbmgo , 12 Dec 2018 21:32
Formatting issues
jbnv jbnv 04 Mar 2015 16:26

I can't get this button and the G+ button to float to the left properly. I've tried style="float:left", style="display:inline-block" and class="pull-left" in Bootstrap. In all three cases, the elements have enormouse amounts of whitespace, both vertical and horizontal. See http://bienv.com/sandbox-xref for an illustration. I want to remove all of the whitespace. Can anyone help me with this?

by jbnv jbnv , 04 Mar 2015 16:26
EricT EricT 16 Feb 2012 14:13

This was a great snippet but I don't know if everybody realizes that the basic tweet button will work fine now in a live template..there is no need to put in the url of make a button for every page. Unless you want to…

Last edited on 16 Feb 2012 14:14 by EricT
by EricT EricT , 16 Feb 2012 14:13
tweet counts not accurate
EricT EricT 24 Mar 2011 12:17

Hey this has been very useful and I do not want to be a pain. But I've noticed that the tweet counts are not always accurate. This is a minor concern but is there any easy solution to this? I know I read something Twitter explanation about increasing the accuracy of the counts…

I just thought I'd mention it but it is not a big deal of course. The counts are close enough.

by EricT EricT , 24 Mar 2011 12:17
%%link%% and %%title%% links not working
WikiWealth WikiWealth 02 Mar 2011 22:47

When I use the %%title%% in my live template it gives this as a results: "Check out this page… %%title%% http://t.co/mwkPtS8 via @wikiwealth"

The title doesn't render. When I use the %%link%%, it gives an error.

Has anyone else gotten this to work in a live template?

This is the example page: http://www.wikiwealth.com/etf-fund-research:ltl

This is the Live template: http://www.wikiwealth.com/include:middle-etf

Thank you,

by WikiWealth WikiWealth , 02 Mar 2011 22:47
Re: %%link%% and %%title%% links not working
leiger leiger 02 Mar 2011 23:58

What source code are you using for the following two pages?

Being able to see the source code should help to identify the problem.


~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server

by leiger leiger , 02 Mar 2011 23:58
Re: %%link%% and %%title%% links not working
WikiWealth WikiWealth 03 Mar 2011 00:02

I think you solved it anyways. Live template versus an include. That's the problem. Thank you Shane.

by WikiWealth WikiWealth , 03 Mar 2011 00:02
Re: %%link%% and %%title%% links not working
leiger leiger 03 Mar 2011 00:08

You can keep the code in the include if you want, but all that means is that you should add this to the etf-fund-research:_template page:

[[include include:middle-etf]]

Even though the variables are on the include page, they are going through the live template.

Edit: At least, I think you can do it that way. Am only guessing what your source code is ;-) Glad to help out.


~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server

Last edited on 03 Mar 2011 00:09 by leiger
by leiger leiger , 03 Mar 2011 00:08
EricT EricT 30 Jan 2011 20:16

Awesome, you rock. That fixed the problem. Thanks for the straight forward explanation. I was using a table for those social buttons like this:

[[table style="float:right;padding: 10px;"]]
[[row]]
[[cell style="padding: 1px; vertical-align: top"]]
[[social facebook, digg, del.icio.us, reddit]] 
[[/cell]]
[[cell style="width: 110px; height: 20px; padding: 1px; vertical-align: bottom"]]
[[include :snippets:tweet-button
|url=%%link%%
|text=%%title%%
|via=GUStrength
|count=horizontal]]
[[/cell]]
[[/row]]
[[/table]]

So as you can see I just put the dimensions in the cell containing the include. It's perfect now. This will help me in the future as well, I bet. Thanks again, Bryce. And sorry I didn't mean to go on and on about things that were probably obvious to you. I just wanted to make sure I was describing the problem properly.

Last edited on 30 Jan 2011 20:17 by EricT
by EricT EricT , 30 Jan 2011 20:16
EricT EricT 30 Jan 2011 00:38

One problem I'm having is that the button takes up a lot of space. Seems like over 300 px. So if I try to include it next to other social buttons I get a big space between. Is the button set to a certain width and is their any way to include the option to control the width as needed? I guess the problem is with twitter's javascript but is there any way around it?

I know that the actual dimensions of the tweet button with horizontal count, according to twitter is: 110 pixels wide and 20 pixels high. The 110 pixel width is made up from 55 pixels for the button, 3 pixels for the space separating the count from the button and 52 pixels for the count itself.

However, it takes up a space of about 285 pixels.

Here is an example:

http://www.gustrength.com/admin:social

The first two versions I want to float to the far right but there is no way to get away from that extra space. This seems to go back to what MDesign said it not floating right like it should..even though you've changed the align function.

The third version is using a button made from twitter's "make your own button" code, just used between html tags as an example. Same problem.

This next version is using an iframe version which solves the problem of the extra space and puts the elements where I want them:

http://www.gustrength.com/admin:social2

You can see the same problem here: http://snippets.wikidot.com/code:new-wikidot-twitter-widget-css3-style

The twitter button is supposed to be floated to the right and it isn't really.

Last edited on 30 Jan 2011 01:35 by EricT
by EricT EricT , 30 Jan 2011 00:38
bcammo bcammo 30 Jan 2011 07:40

EricT said:
One problem I'm having is that the button takes up a lot of space. Seems like over 300 px.

Yep, this is because of the way HTML blocks are rendered with very convoluted markup - you end up with iframes inside body elements inside a paragraph - it all gets very confusing. The best way to overcome this is to wrap the include in a div with the dimensions you want - that way everything is wrapped up in a neat little bundle that you can position however you like.

[[div style="float: right; width: 110px; height: 20px;"]]
[[include :snippets:tweet-button
|url=
|text=
|via=
|count=horizontal
|align=right
]]
[[/div]]

The reason the button isn't aligned properly on the twitter widget snippet page you linked to is because it hasn't been updated to use the new align property.

The other pages you linked to are private so I cannot see your examples. If you have any other questions I'll be only too happy to answer them.

Cheers,
Bryce

by bcammo bcammo , 30 Jan 2011 07:40
EricT EricT 29 Jan 2011 23:24

This has helped me a lot. I would definitely to be able to do the facebook like button in the same way, like MDesign mentioned, to be used in a live template. I've found the like buttons very useful. Anyway, great job on this.

by EricT EricT , 29 Jan 2011 23:24
Question: not make it secure ( blocking the source) ?
eichbehl eichbehl 30 Nov 2010 13:32

Hi bcammoi,
ist it not a good idea to "block" the codes from changing by any visitor or by yourself by accident ( forcing a new variable version nu,er to make a new version wiothot disturbing the pold ones…)

or - are the editing rights as I hope - onl yfor the author itself?

by eichbehl eichbehl , 30 Nov 2010 13:32
Re: Question: not make it secure ( blocking the source) ?
bcammo bcammo 01 Dec 2010 07:32

That's something for the administrators of the site to decide on.

by bcammo bcammo , 01 Dec 2010 07:32
Re: Question: not make it secure ( blocking the source) ?
eichbehl eichbehl 01 Dec 2010 08:01

You are right - I had a look - only the Authors and admins can change a snippet code…

by eichbehl eichbehl , 01 Dec 2010 08:01
Matt Gentile Matt Gentile 28 Nov 2010 21:49

Now for a Facebook "Like" button/counter. You can achieve this the same way as the twitter button.

Edit: Or better yet, an "Add This" share button/counter. It's still in beta mode but I'm sure it will work too.


CEO of Icon Deposit
Take a look at me via Twitter, Dribbble, and Google +

Last edited on 28 Nov 2010 21:54 by Matt Gentile
by Matt Gentile Matt Gentile , 28 Nov 2010 21:49
page 1 of 21
page revision: 12, last edited: 16 Feb 2012 01:49
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License
Click here to edit contents of this page.
Click here to toggle editing of individual sections of the page (if possible). Watch headings for an "edit" link when available.
Append content without editing the whole page source.
Check out how this page has evolved in the past.
If you want to discuss contents of this page - this is the easiest way to do it.
View and manage file attachments for this page.
A few useful tools to manage this Site.
Change the name (also URL address, possibly the category) of the page.
View wiki source for this page without editing.
View/set parent page (used for creating breadcrumbs and structured layout).

AltStyle によって変換されたページ (->オリジナル) /