Search This Blog

Monday, 28 May 2012

How to Create A Custom ‘Tweet This’ Button For Your Facebook Fan Page



In this tutorial we will teach you how to create your own custom Twitter ‘Tweet This’ button for your Facebook Fan page. The goal of this tutorial is to make this button look exactly like the Facebook FBML ‘Share’ button using CSS. We have provided 2 different yet simple options to accomplish this.
EXAMPLE OF THE FACEOOK FBML SHARE BUTTON:

How to Create A Custom ‘Tweet This’ Button For Your Facebook Fan Page




STEP 1: Getting the Twitter Code

Simple “Tweet This” Code

Before we can create the button, you will first need the ‘Tweet This’ code. Keep in mind that this line of code is the only working ‘Tweet’ code inside of a static FBML page. This line of code will be modified and adapted in the following step’s options to produce the styled Facebook version.
1<a title="Your Title Here" href="http://twitter.com/home/?status=Your Message Here">Tweet</a>
Tweet

STEP 2: Creating the CSS ‘Tweet’ Button

Option #1 – Pulling from Facebook’s Style Sheet

The first option to create the custom ‘Tweet” Button is the easiest for making the button fall in line with Facebook’s style of the ‘Share’ button because we will be using exactly that, Facebook’s style. We have set up the code to mimic the way Facebook sets up the ‘Share’ button creating a flawless Facebook styled ‘Tweet’ button by utilizing some of their CSS classes. Copy and modify the code below, happy tweeting!
1<a title="Your Title Here" rel="dialog" href="http://twitter.com/home/?status=Your Message Here" class="uiButton uiButtonDefault uiButtonMedium">
2<i class="mrs img sp_6isv8o sx_368f44"></i><span class="uiButtonText">Tweet</span></a>
3</a>

Option #2 – Custom CSS with Background Image

The second option is a safer choice just in case Facebook decides to change their code (which
they often do). This option relies on using your own CSS along with an image stored on your server, the benefits to this are that you control the code and images and can basically change the style to anything you want. You will need to create the background image or you can save ours directly, please do not link back to our image, save it and use it on your server. If you want to use any wording longer than Tweet you will need to modify the length of the background image to accommodate longer text, or you can get more creative with the CSS and multiple images to create a repeating re sizable button. After your background image is created copy and modify the code below, happy tweeting!
CSS
01#button{
02width: 60px;
03height: 25px;
04float: left;
05position: relative;
06line-height: 22px;
07background: url(yoursite.com/background_image.png) no-repeat top center;
08}
09.tweet{
10font-family:"Lucida Grande","Lucida Sans Unicode", sans-serif;
11font-size: 11px;
12font-weight: bold;
13padding: 0 0 0 18px;
14}
15.tweet a{ color: #333; text-decoration: none; }
16.tweet a:hover{ text-decoration: underline; }
CODE
1<div id="button">
2  <div class="tweet">
3    <a href="http://twitter.com/home/?status=http://twitter.com/home/?status=your message here" target="_blank">Tweet</a>
4  </div>
5</div>

No comments:

Post a Comment