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

Tweet This Topic

Sends a link to a topic to Twitter. Hashtags, topic title 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 Topic

Postby kenny » 08 Mar 2009, 20:34

Twitter seems to be getting more popular and I myself have found myself delving into the api's a few times already. This little snippet is a request from andrew55 in this topic on phpbb.com.

Simple enough - as per the topic title, this snippet allows you to tweet this topic. If you're not logged in when you click the link, simply log in and you'll redirected with the tweet still kept (not done by me, you can thank twitter devs for that ;))

For a demo, check these very forums. I have it here ^_^

OPEN: viewtopic.php
FIND:
Code: Select all
// Send vars to template  

Code: Select all
$hashtag        = ' #phpBB #6StringMODs'; 

Comment:
Feel free to change your hashtags to whatever your feel like - your own sitename perhaps. It would also be nice to tweet this topic/post/page via your won account :P

FIND:
Code: Select all
   'WARN_IMG'         => $user->img('icon_user_warn', 'WARN_USER'),

AFTER ADD:
Code: Select all
   'TWEET_TOPIC'         => urlencode('Read This: ') . generate_board_url() . "/viewtopic.$phpEx?f=$forum_id%26t=$topic_id" . htmlspecialchars(urlencode($hashtag)),

OPEN: language/en/viewtopic.php
FIND:
Code: Select all
   'SUBMIT_VOTE'         => 'Submit vote',

AFTER ADD:
Code: Select all
   'TWEET_TOPIC'         => 'Tweet this topic',

OPEN: styles/prosilver/template/viewtopic_body.html
FIND:
Code: Select all
</h2>

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

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;
}

And just for you lot, I already have created a little twitter logo. Although you can replace if you so wish :P There's plenty in the internet to choose from :)
twitter-logo.png
twitter-logo.png (552 Bytes) Viewed 1529 times
Last edited by kenny on 27 Aug 2009, 09:10, edited 6 times in total.
Reason: Updated code to include hashtags
|| 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: 647
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 Topic

Postby kenny » 08 Mar 2009, 20:44

Just to add to this, on tweeting this topic to test it out, I've noticed that twitter will automatically convert the link to tinyurl :mrgreen:
http://twitter.com/stickerboy/status/1297538190
Last edited by kenny on 10 Mar 2009, 00:18, edited 1 time in total.
Reason: updated post title to reflect 1st post
|| 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: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Tweet This Topic

Postby MookieJ » 10 Mar 2009, 15:36

kenny wrote:For a demo, check these very forums. I have it here ^_^


I don't see the twitter image anywhere :?:
User avatar
MookieJ
Registered User
Registered User
 
Posts: 7
Joined: 09 Mar 2009, 00:01

Tweet This Topic

Postby kenny » 10 Mar 2009, 17:19

Hi MookieJ,

Can you give me a link to your board please and I'll have a look :)


Kenny.
|| 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: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Tweet This Topic

Postby RMcGirr83 » 10 Mar 2009, 18:11

kenny wrote:Hi MookieJ,

Can you give me a link to your board please and I'll have a look :)


Kenny.


I think he means on here. The icon is located next to the topic title towards the top of the page.
User avatar
RMcGirr83 RMcGirr83 has donated to 6 String MODs
V.I.P
V.I.P
 
Posts: 12
Joined: 10 Mar 2009, 18:08

Tweet This Topic

Postby kenny » 10 Mar 2009, 21:35

Ah, hehe that makes sense :P
I also recently renamed this snippet to "Tweet this topic" from "Tweet this post". Tempted to do an actual "Tweet this post" snippet though. I'm getting Twitter daft. I'm a twit :shock: :lol:
|| 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: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Tweet This Topic

Postby MookieJ » 10 Mar 2009, 22:33

Ok, I opened in firefox and I see it, but it doesn't show in IE7 :shock:

edit-- and I installed on my board, and I do not see the icon in either firefox or IE :(
User avatar
MookieJ
Registered User
Registered User
 
Posts: 7
Joined: 09 Mar 2009, 00:01

Tweet This Topic

Postby MookieJ » 10 Mar 2009, 22:56

OK, My style is different..Where exactly would I put this?
Code: Select all
<a href="http://twitter.com/home?status={TWEET_TOPIC}" class="tweet-link" title="{L_TWEET_TOPIC}"></a>


here's some of my viewtopic_body.html
Code: Select all
<!-- BEGIN postrow -->
   <!-- IF postrow.S_FIRST_UNREAD --><a id="unread"></a><!-- ENDIF -->
      <div id="p{postrow.POST_ID}" class="post <!-- IF postrow.POST_EXPIRE -->bg3<!-- ELSEIF postrow.S_ROW_COUNT is odd -->bg1<!-- ELSE -->bg2<!-- ENDIF --><!-- IF postrow.S_UNREAD_POST --> unreadpost<!-- ENDIF --><!-- IF postrow.S_POST_REPORTED --> reported<!-- ENDIF --><!-- IF postrow.S_ONLINE --> online<!-- ENDIF -->"style="border: 1px solid #7cb251;">
   
      <div class="inner"><span class="corners-top"><span></span></span>

      <div id="c-sig{postrow.POST_ID}"class="postbody">
         <!-- IF postrow.S_IGNORE_POST -->
            <div class="ignore">{postrow.L_IGNORE_POST}</div>
         <!-- ELSE -->

      <!-- IF not S_IS_BOT -->
         <!-- IF postrow.U_QUOTE or postrow.U_INFO or postrow.U_DELETE or postrow.U_EDIT -->
            <ul class="profile-icons">
               <!-- IF postrow.U_EDIT --><li class="edit-icon"><a href="{postrow.U_EDIT}" title="{L_EDIT_POST}"><span>{L_EDIT_POST}</span></a></li><!-- ENDIF -->
               <!-- IF postrow.U_DELETE --><li class="delete-icon"><a href="{postrow.U_DELETE}" title="{L_DELETE_POST}"><span>{L_DELETE_POST}</span></a></li><!-- ENDIF -->
               <!-- IF postrow.U_REPORT --><li class="report-icon"><a href="{postrow.U_REPORT}" title="{L_REPORT_POST}"><span>{L_REPORT_POST}</span></a></li><!-- ENDIF -->
               <!-- IF postrow.U_WARN --><li class="warn-icon"><a href="{postrow.U_WARN}" title="{L_WARN_USER}"><span>{L_WARN_USER}</span></a></li><!-- ENDIF -->
               <!-- IF postrow.U_INFO --><li class="info-icon"><a href="{postrow.U_INFO}" title="{L_INFORMATION}"><span>{L_INFORMATION}</span></a></li><!-- ENDIF -->
               <!-- IF postrow.U_QUOTE --><li class="quote-icon"><a href="{postrow.U_QUOTE}" title="{L_REPLY_WITH_QUOTE}"><span>{L_REPLY_WITH_QUOTE}</span></a></li><!-- ENDIF -->
            </ul>
         <!-- ENDIF -->
      <!-- ENDIF -->

         <h3 <!-- IF postrow.S_FIRST_ROW -->class="first"<!-- ENDIF -->><!-- IF postrow.POST_ICON_IMG --><img src="{T_ICONS_PATH}{postrow.POST_ICON_IMG}" width="{postrow.POST_ICON_IMG_WIDTH}" height="{postrow.POST_ICON_IMG_HEIGHT}" alt="" /> <!-- ENDIF --><a href="#p{postrow.POST_ID}">{postrow.POST_SUBJECT}</a></h3>
         <p class="author"><!-- IF S_IS_BOT -->{postrow.MINI_POST_IMG}<!-- ELSE --><a href="{postrow.U_MINI_POST}">{postrow.MINI_POST_IMG}</a><!-- ENDIF -->{L_POST_BY_AUTHOR} <strong>{postrow.POST_AUTHOR_FULL}</strong> &raquo; {postrow.POST_DATE} <!-- IF postrow.POST_EXPIRE -->&nbsp;&nbsp;&nbsp;<strong>{L_POST_WILL_EXPIRE}:</strong> {postrow.POST_EXPIRE}<!-- ENDIF -->

</p>

         <!-- IF postrow.S_POST_UNAPPROVED or postrow.S_POST_REPORTED -->
            <p class="rules">
               <!-- IF postrow.S_POST_UNAPPROVED -->{UNAPPROVED_IMG} <a href="{postrow.U_MCP_APPROVE}"><strong>{L_POST_UNAPPROVED}</strong></a><!-- ENDIF -->
               <!-- IF postrow.S_POST_REPORTED -->{REPORTED_IMG} <a href="{postrow.U_MCP_REPORT}"><strong>{L_POST_REPORTED}</strong></a><!-- ENDIF -->
            </p>
         <!-- ENDIF -->

         <div class="content">{postrow.MESSAGE}</div>

         <!-- IF postrow.S_HAS_ATTACHMENTS -->
            <dl class="attachbox">
               <dt>{L_ATTACHMENTS}</dt>
               <!-- BEGIN attachment -->
                  <dd>{postrow.attachment.DISPLAY_ATTACHMENT}</dd>
               <!-- END attachment -->
            </dl>
         <!-- ENDIF -->

         <!-- IF postrow.S_DISPLAY_NOTICE --><div class="rules">{L_DOWNLOAD_NOTICE}</div><!-- ENDIF -->
         <!-- IF postrow.EDITED_MESSAGE or postrow.EDIT_REASON -->
            <div class="notice">{postrow.EDITED_MESSAGE}
               <!-- IF postrow.EDIT_REASON --><br /><strong>{L_REASON}:</strong> <em>{postrow.EDIT_REASON}</em><!-- ENDIF -->
            </div>
         <!-- ENDIF -->

         <!-- IF postrow.BUMPED_MESSAGE --><div class="notice">{postrow.BUMPED_MESSAGE}</div><!-- ENDIF -->
         
      <!-- ENDIF -->

      </div>

      <!-- IF not postrow.S_IGNORE_POST -->
         <dl class="postprofile" id="profile{postrow.POST_ID}">
         <dt>
            <!-- IF postrow.POSTER_AVATAR -->
               <!-- IF postrow.U_POST_AUTHOR --><a href="{postrow.U_POST_AUTHOR}">{postrow.POSTER_AVATAR}</a><!-- ELSE -->{postrow.POSTER_AVATAR}<!-- ENDIF --><br />
            <!-- ENDIF -->
            <!-- IF not postrow.U_POST_AUTHOR --><strong>{postrow.POST_AUTHOR_FULL}</strong><!-- ELSE -->{postrow.POST_AUTHOR_FULL}<!-- ENDIF -->
         </dt>

         <!-- IF postrow.RANK_TITLE or postrow.RANK_IMG --><dd>{postrow.RANK_TITLE}<!-- IF postrow.RANK_TITLE and postrow.RANK_IMG --><br /><!-- ENDIF -->{postrow.RANK_IMG}</dd><!-- ENDIF -->

      <dd>&nbsp;</dd>



Thanks in advance, and I hope you can get this working for IE too :)
User avatar
MookieJ
Registered User
Registered User
 
Posts: 7
Joined: 09 Mar 2009, 00:01

Tweet This Topic

Postby kenny » 10 Mar 2009, 23:02

It's the very top of viewtopic_body.html that you're looking at ;)
If it doesn't show, try purging the cache and refreshing your theme from the ACP
ps. It works for me in IE8 (Windows7) :)
|| 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: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Tweet This Topic

Postby MookieJ » 10 Mar 2009, 23:15

OK, I got the placement right. But It just will not show up in IE7. I did purge and refresh. It doesn't show up here (on your site) either for me in IE7. If I put my cursor over where the image should be, I can click and go to my twitter page, however the image is just not showing up. :?
User avatar
MookieJ
Registered User
Registered User
 
Posts: 7
Joined: 09 Mar 2009, 00:01

Next



Return to Code Snippets

Who is online

Google [Bot]


cron