PDA

View Full Version : Tweet button for every post?


JamesAB
05-26-2016, 06:39 PM
Has anyone done a simple plugin or mod to add a tweet button for every post? Basically a button that open a new window so user's can tweet that post's URL and tread title from their own twitter account.

I need something that works with VB3.8

I don't want to start from scratch if this is already available.

Thanks,
James

greigeh
05-26-2016, 10:11 PM
<a href="https://vborg.vbsupport.ru/showthread.php?t=248568" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=248568</a> came up in similar threads, this is dated back to 2012 so can imagine it is out of date, but using the correct twitter URL/if conditions can imagine this is easily done.

JamesAB
05-28-2016, 11:00 AM
Thanks. That's a good start, however Twitter has changed their API so now I need to make some adjustments.

I guess fist I need to find a plugin location where I can grab the thread title and post URL and make these two variables URL encoded. Then I can form a valid URL to link to create a Twitter Tweet Web Intent link to place in the postbit template.

Any suggestions for the best place to create these two URL encoded variables?

PinkMilk
05-29-2016, 11:36 PM
Ok so this is what I got...


<a href="https://twitter.com/share?url=$vboptions[bburl]/showpost.php?$session[sessionurl]p=$post[postid]&amp;postcount=$post[postcount]&text=$thread[title]" target="_blank">Tweet</a>



Add anywhere in postbit/postbit_legacy template should work.

Breakdown

The single post page link:
$vboptions[bburl]/showpost.php?$session[sessionurl]p=$post[postid]&amp;postcount=$post[postcount]

Thread title variable:
$thread[title]

target blank to open in new window:
target="_blank"

Mattwhf
06-22-2016, 10:51 AM
Ok so this is what I got...


<a href="https://twitter.com/share?url=$vboptions[bburl]/showpost.php?$session[sessionurl]p=$post[postid]&amp;postcount=$post[postcount]&text=$thread[title]" target="_blank">Tweet</a>



Add anywhere in postbit/postbit_legacy template should work.

Breakdown

The single post page link:
$vboptions[bburl]/showpost.php?$session[sessionurl]p=$post[postid]&amp;postcount=$post[postcount]

Thread title variable:
$thread[title]

target blank to open in new window:
target="_blank"

If I put this in sidebar it can run for all forum pages?

PinkMilk
06-23-2016, 06:38 AM
No the above code is for individual posts, for a single link to showthread page you would need something like this:

<a href="https://twitter.com/share?url=$vboptions[bburl]/showthread.php?t=$threadinfo[threadid]&text=$thread[title]" target="_blank">Tweet</a>

This would normally be added to SHOWTHREAD template, however if you want it in a sidebar which I'm guessing is on everypage you would need to wrap it in a conditional so it only shows on a showthead page.

<if condition="THIS_SCRIPT == 'SHOWTHREAD'">
<a href="https://twitter.com/share?url=$vboptions[bburl]/showthread.php?t=$threadinfo[threadid]&text=$thread[title]" target="_blank">Tweet</a>
</if>

----------------------------------------------------

Update:

Just re-read you post and sounds more like you just want a basic tweet button this would be done using:
<a href="https://twitter.com/share?url=$vboptions[bburl]/&text=$vboptions[bbtitle]" target="_blank">Tweet</a>

However it will just post your forum url and title.