Page 1 of 1

Tweet This Page

PostPosted: 21 Mar 2009, 17:33
by kenny
Easier than I thought to do this, once I found how to shorten the URL's :) Again, same idea as my "Tweet this topic" and "Tweet this post" snippets.

Comment:
I realise that some web hosts may block the use of file_get_contents, but there are many workarounds available. A quick Google search for an {TEXT} should do the trick ;)


OPEN: includes/functions.php
FIND:
Code: Select all
/**
* Generate page header
*/
 

AFTER ADD:
Code: Select all
/**
* Put in a long URL, get a short one back out
* http://www.scripting.com/stories/2007/06/27/tinyurlHasAnApi.html
* http://fyneworks.blogspot.com/2008/08/tiny-url-api.html
*/
function TinyURL($u)
{
    return file_get_contents('http://tinyurl.com/api-create.php?url=' . urlencode($u));
}
 

FIND:
Code: Select all
        'ROOT_PATH'            => $phpbb_root_path, 

AFTER ADD:
Code: Select all
        'TWEET_PAGE'            => urlencode('Check out this page: ') . TinyURL(generate_board_url() . $_SERVER['REQUEST_URI']), 

OPEN: language/en/common.php
FIND:
Code: Select all
   'TRACKED_PHP_ERROR'   => 'Tracked PHP errors: %s',

AFTER ADD:
Code: Select all
   'TWEET_PAGE'         => 'Tweet this page',

OPEN: styles/prosilver/template/overall_header_body.html
FIND:
Code: Select all
Somewhere in the header that you think would suit

ADD:
Code: Select all
<span class="tweet-link"><a href="http://twitter.com/home?status={TWEET_PAGE}" class="tweet-link" title="{L_TWEET_PAGE}"></a></span>

Comment:
If you have already installed "Tweet this topic/post", then you can skip the next 2 steps and go straight to purging your cache

OPEN: styles/prosilver/theme/colours.css
FIND:
Code: Select all
a.right:hover {
   color: #5E7BAA;
}

AFTER ADD:
Code: Select all
.tweet-link a {
   float: left;
   background-image: url("{T_THEME_PATH}/images/twitter-logo.png");
   padding-left:18px;
   height: 18px;
   background-repeat: no-repeat;
   position: absolute;
}

Twitter logo - download/file.php?id=73

Tweet This Page

PostPosted: 21 Mar 2009, 20:01
by cs278
Code: Select all
return file_get_contents('http://tinyurl.com/api-create.php?url=' $u); 

Should be:
Code: Select all
return file_get_contents('http://tinyurl.com/api-create.php?url=' urlencode($u)); 

Tweet This Page

PostPosted: 21 Mar 2009, 20:03
by kenny
Doh! I wasn't thinking when I pasted that. Cheers :)