vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Template Modifications (https://vborg.vbsupport.ru/forumdisplay.php?f=246)
-   -   Show Thread Enhancements - Twitter - Tweet Button in SHOWTHREAD (https://vborg.vbsupport.ru/showthread.php?t=248569)

BirdOPrey5 08-13-2010 10:00 PM

Twitter - Tweet Button in SHOWTHREAD
 
1 Attachment(s)
This mod is now outdated and as a result support for new installs will be limited, if any.

-July 7, 2011-

Please instead use my new mod which offers Twitter and many more share options for VB 4.x without template edits.

WARNING - It appears vBulletin has changed the location of the Facebook Like button in version 4.1.2. As a result it is likely the code changes below will be different in 4.1.2 and beyond, I will not be able to support installs beginning with version 4.1.2 since my license stops at 4.0.8.


Twitter released their new TWEET button.

Live Demo: http://www.juot.net/forums/showthread.php?t=41185
(Note my Live Board is VB 3.8, but I have tested this on 4.0.4 and 4.0.6)
(Update I have for the time being replaced the Tweet button with the Add This share button on my live forum. See the screen shots instead.)

I have tested this in latest versions of IE / Firefox / Chrome / Safari / Opera and it should work in all.

This will show you how to add this simple code to your SHOWTHREAD template above the page navigation bar, if visible.

If you DO NOT use the built-in Facebook Like button do the following:

Go to the Admin CP -> Styles & Templates -> Style Manager
Edit your SHOWTHREAD Template

Find: (The first instance of)
Code:

                <vb:if condition="$pagenav">
                        {vb:raw pagenav}
                </vb:if>

Above this add:
Code:

<vb:if condition="!in_array($GLOBALS[forumid], array(X, Y, Z))">
<div id="mytweetbutton" align="right" style="height:27px;">
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="YOUR_TWITTER_USERNAME">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</div>
</vb:if>

Change the X, Y, Z in the first line to the forumid's of any private forums you may have. If a guest can't view a forum there is no reason to link a tweet to it. You can add as many or as few forumid's here as you need, just separate each with a comma.
Valid Examples:
<vb:if condition="!in_array($GLOBALS[forumid], array(2, 5, 9))">
<vb:if condition="!in_array($GLOBALS[forumid], array(7))">
<vb:if condition="!in_array($GLOBALS[forumid], array(2, 3, 4, 5, 6, 7, 8))">
If none of your forums are private or you want to enable this in every forum you can remove the lines:
Code:

<vb:if condition="!in_array($GLOBALS[forumid], array(X, Y, Z))">
and
</vb:if>

Replace "YOUR_TWITTER_USERNAME" with your twitter username, it will be referenced in the tweet- but the tweet will not be from YOU, it will be from whoever hits the tweet button.

If you DO USE the built-in Facebook Like button do the following:

Find:
Code:

                {vb:raw fblikebutton}
Replace it with:
Code:

<div id="fb_likeframe" style="border: none; overflow: hidden; height: 27px; width: 95px; vertical-align: text-bottom; padding-top:1px;"><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="YOUR_TWITTER_USERNAME">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>{vb:raw fblikebutton}
Replace "YOUR_TWITTER_USERNAME" with your twitter username, it will be referenced in the tweet- but the tweet will not be from YOU, it will be from whoever hits the tweet button.

The Tweet button will now show up next to the Facebook Like button in anytime the Facebook Like button is displayed in a thread.

----

When you hit the Tweet button you will be given a box to type a message if you're logged in. If you're not logged in you will be asked to login or join, all within the pop-up window.

This button code will count the number of tweets people have made using it. For other options including the button with no counter visit: http://twitter.com/goodies/tweetbutton

The screen shots show the Tweet button both with and without the page navigation bar, and with the Facebook Like button.

Please click Install if you use this. :)

Download the .txt file for a copy of the install instructions. :up:

----

Known Issues- a few people have reported a 'slash' is missing in the URL submitted to Twitter on some boards. Other people have said URL's with non-english characters cause a URL error. The solution for both of these issues is in post #143 in this thread.

Also Twitter appears to be having widespread issues with the counter not working. Some sites it works, some it don't, sometimes it stops working, sometimes it starts working for no reason. If you find your count isn't working try the solution in post #147. If that doesn't work than disable your counter completely if you want by changing the word "horizontal" to "none" in the twitter code.

CMSTemplateZ 08-14-2010 12:15 PM

Cheers for this.... i saw this on DP today.. looks like a handy little addon, i just want to use on the main page so i guess i just need to add the divs without the conditionals ?

Thanks

BirdOPrey5 08-14-2010 12:46 PM

If you want to add it to only your main forum page you'd edit the FORUMHOME template instead. I'd recommend finding the code:

Code:

{vb:raw navbar}
And Below this adding:
Code:

<div id="mytweetbutton" align="right" style="height:30px;">
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="YOUR_TWITTER_USERNAME">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</div>

So you would not need the conditionals, correct.

Note- if you have the VB4 Suite and want to add it to your main page of the suite you'd have to edit some other template- I don't have the Suite so I can't help you with that.

CMSTemplateZ 08-14-2010 01:43 PM

Quote:

Note- if you have the VB4 Suite and want to add it to your main page of the suite you'd have to edit some other template- I don't have the Suite so I can't help you with that.
Thanks bud for a quick reply... i worked it out.... See Here: http://battlefield3forums.com/content/

I added it to the start of the breadcrumb div and wrapped it in my own custom div to style it a little better... because the facebook like text color can not be changed it's kinda hard to see i will keep playing around with it.

Thanks for this, just hope people still click these buttons, now that every site seems to have them numbers have dropped alot, hopefully the tweet button gets people clicking it.

Cheers again for posting this

BirdOPrey5 08-14-2010 01:58 PM

Looks Good.

baghdad4ever 08-14-2010 05:23 PM

installed

but there is problem

it send this

http://www.baghdad4ever.netshowthread.php/299978

instead of this url

http://www.baghdad4ever.net/vb/showthread.php/299978

how to fix that?

BirdOPrey5 08-14-2010 05:27 PM

If you go to vbulletin options -> Site Name / URL / Contact Details
are your forum URL and Homepage URL correct?
It looks like your forum url should be: http://www.baghdad4ever.net/vb/

baghdad4ever 08-14-2010 05:30 PM

hi

yes my friend i used http://www.baghdad4ever.net/vb

but i dont know why this problem occur

is there any modification to the code in order to enforce the button to take the forum url?

baghdad4ever 08-14-2010 05:45 PM

i used this code

Code:

<div id="mytweetbutton" align="right" style="height:30px;">
<a href="http://twitter.com/share?url=http://www.baghdad4ever.net/vb/{vb:link thread, {vb:raw thread}}" class="twitter-share-button" data-count="horizontal" data-via="twitter_username">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</div>


is that ok?

BirdOPrey5 08-14-2010 06:02 PM

It's OK if it works! :)

Another option is I see you have a facebook tag in the header/header include...
<meta property="og:url" content="YOUR CODE HERE" />
You could add the following line under that:
<link rel="canonical" href="YOUR CODE HERE" />

Use the same code you use for your facebook og:url tag in the canonical tag and that will override the URL the tweet button sends.

BirdOPrey5 08-14-2010 06:12 PM

I went to your page, it looks like whatever you're doing is working. :)

baghdad4ever 08-14-2010 07:17 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2083865)
I went to your page, it looks like whatever you're doing is working. :)


thank u very much:D

zurrie 08-14-2010 07:19 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2083863)
Another option is I see you have a facebook tag in the header/header include...
<meta property="og:url" content="YOUR CODE HERE" />
You could add the following line under that:
<link rel="canonical" href="YOUR CODE HERE" />

Use the same code you use for your facebook og:url tag in the canonical tag and that will override the URL the tweet button sends.

Hi,

1. Could you explain what is "header/header include" ?

2. is there anyway to put automativ trailing slash on your mod?

nice mode btw, thanks for sharing.

Zurrie

zelnik 08-14-2010 07:23 PM

1 Attachment(s)
I guess Showthread has changed in 4.0.6 as your edits do not work.

I've tried it above and below where you have said to enter it and do not get the desired affect.

Also on your site if you click on the number next to the tweet it finds nothing on Twitter, however I checked on DP and theirs works ok?

See attachment for location problems.

zurrie 08-14-2010 07:35 PM

1 Attachment(s)
This is looks in 4.0.5.

zurrie 08-14-2010 07:42 PM

Quote:

Originally Posted by zurrie (Post 2083907)
This is looks in 4.0.5.

update!

i change the height into 50px resolve the space in 4.0.5.

Regards,

Zurrie

BirdOPrey5 08-14-2010 08:07 PM

Quote:

Originally Posted by zurrie (Post 2083901)
Hi,

1. Could you explain what is "header/header include" ?

2. is there anyway to put automativ trailing slash on your mod?

nice mode btw, thanks for sharing.

Zurrie

The "header" or "header include" templates, accessible by Admin CP -> Styles & Templates -> Style Manager -> (Your Style) -> All Style Options... These will be the first two boxes you see. The code is probably in the second one, "header include."

When you say automatic trailing slash, do you mean to the URL sent to Twitter? I suppose it could be done if you use the canonical link tag I mentioned and typed a "/" at the end.

Quote:

Originally Posted by zelnik (Post 2083902)
I guess Showthread has changed in 4.0.6 as your edits do not work.

I've tried it above and below where you have said to enter it and do not get the desired affect.

Also on your site if you click on the number next to the tweet it finds nothing on Twitter, however I checked on DP and theirs works ok?

See attachment for location problems.

Honestly I don't have Facebook integration installed on mine so that might be what is causing the problem... however zurrie reported changing the div height to 50 seemed to fix this problem.

zelnik 08-14-2010 08:07 PM

Quote:

Originally Posted by zurrie (Post 2083911)
update!

i change the height into 50px resolve the space in 4.0.5.

Regards,

Zurrie

The sites I've seen it working on has it next to the facebook like button which looks far better than having it on top.

zurrie 08-15-2010 03:32 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2083924)
When you say automatic trailing slash, do you mean to the URL sent to Twitter? I suppose it could be done if you use the canonical link tag I mentioned and typed a "/" at the end.

Okay, what i mean is the "result URL" to twitter which is show at "short url" when you click it the result on browser will show as http://www.domain-name.comshowthread.php/XXXX

no trailing slash.

i try to remove my facebook integration but still the same twitter show no trailing slash result.

btw, reminds me which vB you are using sir?

Regards,

Zurrie

BirdOPrey5 08-15-2010 03:39 PM

I'm on 4.0.4 at the moment, will be upgrading to 4.0.6 shortly.

Can you give me a link to your forum so I can see what's going on?
PM me if you don't want it public.

acezakj 08-15-2010 06:35 PM

Could you make a identical facebook one right next to the twitter one? It would be greatly appreciated

BirdOPrey5 08-15-2010 07:12 PM

Doesn't VB4 have facebook integration built in already? You just go to the admin cp -> vbulletin options -> Facebook Options to set it up...

If you are using VB3.x then I recommend this mod, it's what I use in my 3.8 board:
https://vborg.vbsupport.ru/showthread.php?t=243319

For the most part it would work on VB4 if it had to, just put the code in SHOWTHREAD so you don't need those conditionals.

Gleedo 08-17-2010 06:02 AM

Quote:

Originally Posted by CMSTemplateZ (Post 2083730)
Thanks bud for a quick reply... i worked it out.... See Here: http://battlefield3forums.com/content/

I added it to the start of the breadcrumb div and wrapped it in my own custom div to style it a little better... because the facebook like text color can not be changed it's kinda hard to see i will keep playing around with it.

Thanks for this, just hope people still click these buttons, now that every site seems to have them numbers have dropped alot, hopefully the tweet button gets people clicking it.

Cheers again for posting this

I clicked your tweet button as im a member of your forum :)

sbsforum.us 08-18-2010 04:50 AM

Thanks

zelnik 08-18-2010 11:57 AM

Quote:

Originally Posted by BirdOPrey5 (Post 2083924)
Honestly I don't have Facebook integration installed on mine so that might be what is causing the problem... however zurrie reported changing the div height to 50 seemed to fix this problem.

It does work but it bloats the display too much as it goes above the FB and page 123 select.

Look forward to you having 4.0.6 installed and turning on the fb as it will be a lovely addition to my site!

Thanks!

Crowza 08-18-2010 08:09 PM

1 Attachment(s)
Here is what I did to fix the sizing issues for 4.0.6:

1. Find the following code in SHOWTHREAD:

Code:

<vb:if condition="$show['fb_likebutton']">
2. After that line insert your Twitter button code:

Code:

<vb:if condition="!in_array($GLOBALS[forumid], array(21, 22))">   
                                  <div id="mytweetbutton" align="right" style="height:15px;">
                                  <a href="http://twitter.com/share" class="twitter-share-button" data-count="none" data-via="crowzacom" data-related="EdCrowza">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
                                  </div>
                          </vb:if>

3. Make sure you replace the correct variables, per the original instructions (I also added the 'data-related' option for it to recommend more than one Twitter account). Notice, the height is set to '15px;'.

If you do that, it should look like the attached image:

zelnik 08-19-2010 01:39 PM

Quote:

Originally Posted by Crowza (Post 2085964)
Here is what I did to fix the sizing issues for 4.0.6:

1. Find the following code in SHOWTHREAD:

Code:

<vb:if condition="$show['fb_likebutton']">
2. After that line insert your Twitter button code:

Code:

<vb:if condition="!in_array($GLOBALS[forumid], array(21, 22))">   
                                  <div id="mytweetbutton" align="right" style="height:15px;">
                                  <a href="http://twitter.com/share" class="twitter-share-button" data-count="none" data-via="crowzacom" data-related="EdCrowza">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
                                  </div>
                          </vb:if>

3. Make sure you replace the correct variables, per the original instructions (I also added the 'data-related' option for it to recommend more than one Twitter account). Notice, the height is set to '15px;'.

If you do that, it should look like the attached image:

thanks for that is there anyway to get it next to the fb like button?

xtremecoders 08-20-2010 09:30 PM

Nice MOD but i have also Facebook enabled and causing some Overlap with pages display.

http://img3.imageshack.us/img3/8664/clip25.png

UPDATE....

Fixed by Changing Possition of code.....

1. Find the following code in SHOWTHREAD:

Code:

            <div id="postpagestats_above" class="postpagestats">
                {vb:rawphrase showing_results_x_to_y_of_z, {vb:raw pagenumbers.first}, {vb:raw pagenumbers.last}, {vb:raw totalposts}}
            </div>

2. After that line insert your Twitter button code:

Code:

<vb:if condition="!in_array($GLOBALS[forumid], array(X, Y, Z))">
<div id="mytweetbutton" align="right" style="height:50px;">
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="YOUR_TWITTER_USERNAME">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</div>
</vb:if>


http://img96.imageshack.us/img96/6833/clip26.png

zelnik 08-21-2010 08:51 AM

1 Attachment(s)
Quote:

Originally Posted by xtremecoders (Post 2087081)
Fixed by Added bellow.....

Unfortunately that doesn't fix it properly, the pagination is not correct as the " Results 1 to 10 of 17" should be next to the pagination and now it is under the facebook connect.

Also it looks a little odd as it doesn't line up (twit button) should be a couple of pixels higher or ultimately it would look better next to the fb icon I think...

Have a look at the attachments to see what I mean.

xtremecoders 08-21-2010 09:05 AM

Why for me is Just fine ?

https://vborg.vbsupport.ru/

Maybe you don't place it at the right place.
Place the code after the first </div>, NOT the second....

BirdOPrey5 08-21-2010 10:34 AM

I agree the tweet button would look better a couple pixels higher but haven't figured that put yet,

zelnik 08-21-2010 11:05 AM

Quote:

Originally Posted by xtremecoders (Post 2087281)
Why for me is Just fine ?

http://img594.imageshack.us/img594/3470/clip27.png

Maybe you don't place it at the right place.
Place the code after the first </div>, NOT the second....

I will give it another try would be be very difficult to get it onto the same line as the fb connect?! as then you would have the 2 social networking sites next to one another?!

Thanks

BirdOPrey5 08-21-2010 12:14 PM

OK, I have figured out the best place to use this if you also use the Facebook Like button which I guess most do. I have updated the first post with new instructions.

Screen Shot of new location below:

https://vborg.vbsupport.ru/attachmen...1&d=1282396257

zelnik 08-21-2010 01:51 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2087343)
OK, I have figured out the best place to use this if you also use the Facebook Like button which I guess most do. I have updated the first post with new instructions.

Screen Shot of new location below:

Works great however the Twitter box with the number of tweets is cut off on the right so if you change the entry from 90px width to 92px it fixes it.

Is there an easy way of flipping them around to the Twitter button is on the left of the FB button!?

BirdOPrey5 08-21-2010 03:07 PM

Quote:

Originally Posted by zelnik (Post 2087377)
Works great however the Twitter box with the number of tweets is cut off on the right so if you change the entry from 90px width to 92px it fixes it.

Is there an easy way of flipping them around to the Twitter button is on the left of the FB button!?

Thanks I will update the instructions...

I haven't tested this but I'd imagine putting the {vb:raw fblikebutton} code before the twitter code instead of after it, it may work... such as:

EDIT- I did test it and it does work, however the width should be even longer, 95px works nicely.

Code:

{vb:raw fblikebutton}<div id="fb_likeframe" style="border: none; overflow: hidden; height: 27px; width: 95px; vertical-align: text-bottom;"><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="YOUR_TWITTER_USERNAME">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>

vivamexico55 08-21-2010 04:15 PM

Doesn't work with 4.06 and FB Connect enabled, gives me this error:

URL required

'url' parameter does not contain a valid URL.

BirdOPrey5 08-21-2010 04:31 PM

Hmmm... it's definitely working for me... where are you getting this error, in the pop-up window? Is there anything else?

Can you give a link to your forum?

zelnik 08-21-2010 06:11 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2087406)
Thanks I will update the instructions...

I haven't tested this but I'd imagine putting the {vb:raw fblikebutton} code before the twitter code instead of after it, it may work... such as:

EDIT- I did test it and it does work, however the width should be even longer, 95px works nicely.

Thanks works nicely but sods law the icons/buttons are different heights.

Would it be difficult to be able to add the twitter button 1 or 2 pixels lower?

Thanks and marked installed.

BirdOPrey5 08-21-2010 06:32 PM

Quote:

Originally Posted by zelnik (Post 2087464)
Thanks works nicely but sods law the icons/buttons are different heights.

Would it be difficult to be able to add the twitter button 1 or 2 pixels lower?

Thanks and marked installed.

Yeah good call... if you add the code: padding-top:2px; to the style attribute of the <div> tag it perfectly centers the tweet button with the facebook button. I have updated the code in the top post to reflect this change.

zelnik 08-21-2010 07:58 PM

thanks works perfectly!


All times are GMT. The time now is 06:02 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01638 seconds
  • Memory Usage 1,873KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (15)bbcode_code_printable
  • (17)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete