phpBB.com     phpBB Academy     phpBB Modders     phpBB Weekly     ktuk     phpBB Hacks     Vlad Studio  

Tweet This Page

Sends a link to any page to Twitter. Hashtags and ShortURL's are optional

Not enough for a full proper MOD, but too useful not to share
Forum rules
Please read over our forum guidelines

Tweet This Page

Postby kenny » 21 Mar 2009, 17:33

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
Last edited by kenny on 27 Aug 2009, 09:38, edited 2 times in total.
Reason: urlencode added
|| 6 String Romance || Myspace || phpBB.com || Need Freelance Work? ||
If you need one of my MODs installed - click here


Are you a musician in the Glasgow area interested in acoustic events? The ArtBox
User avatar
kenny kenny is probably rawking out on RockBand \m/
Project Leader
Project Leader
 
Posts: 645
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Donate to 6 String MODs
If you like any of the work that I do here, please consider donating.
click the image on the left for a list of some of the advantages of donating



Tweet This Page

Postby cs278 » 21 Mar 2009, 20:01

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)); 
User avatar
cs278 cs278 is a Developer rawr!
Donator
Donator
 
Posts: 3
Joined: 16 Feb 2009, 00:17
Location: Bristol, UK

Tweet This Page

Postby kenny » 21 Mar 2009, 20:03

Doh! I wasn't thinking when I pasted that. Cheers :)
|| 6 String Romance || Myspace || phpBB.com || Need Freelance Work? ||
If you need one of my MODs installed - click here


Are you a musician in the Glasgow area interested in acoustic events? The ArtBox
User avatar
kenny kenny is probably rawking out on RockBand \m/
Project Leader
Project Leader
 
Posts: 645
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK




Return to Code Snippets

Who is online

Google [Bot], MSN [Bot], Yahoo [Bot]


cron