Tweet this topic and/or post

Post your MODs, receive and provide feedback!
Topics in this forum are not for MOD support, they are for giving the author feedback.
Forum rules
The topics in this forum are not for general MOD support, they are for giving the MOD author some feedback, ideas and bug reports.
User avatar
tumba25
Past Contributor
Past Contributor
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.

Tweet this topic and/or post

Postby tumba25 » 01 Nov 2010, 00:01

This was originally posted by Kenny at 6 String MODs, I rewrote the codes and separated them to three posts. The first contains code used by both topic and post tweets. The second is for tweeting topics and the third for tweeting posts.

This thing is submitted to the MODDB at http://www.phpbb.com for validation.

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 [url=http://www.phpbb.com/community/memberlist.php?mode=viewprofile&u=880575]andrew55[/url] in [url=http://www.phpbb.com/community/viewtopic.php?f=72&t=1486425]this topic[/url] 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

$voted_id = (sizeof($voted_id) > 1) ? array_unique($voted_id) : $voted_id;   &nbsp

ADD AFTER:

Code: Select all

if ($auth->acl_get_list(ANONYMOUS, 'f_read', $forum_id))
{
    $s_tweet = true;
    $topic_url = generate_board_url() . '/viewtopic.' . $phpEx . '?t=' . $topic_id;
    $hashtag = htmlspecialchars(urlencode('#phpBBModders'));
}
else
{
    $s_tweet = false;
}&
nbsp;  &nbsp

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 own account :P


Note that you need to refresh both your themes and imagesets after doing these changes.

And just for you lot, [url=http://phpbbmodders.net/board/memberlist.php?mode=viewprofile&u=14]bonelifer[/url] created new twitter buttons. Although you can replace them if you so wish :P There's plenty in the internet to choose from :)
You do not have the required permissions to view the files attached to this post.

User avatar
tumba25
Past Contributor
Past Contributor
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.

Tweet this topic

Postby tumba25 » 01 Nov 2010, 00:03

This post contains edits for tweeting topics. You will also need the code from the first post.

OPEN: viewtopic.php
FIND:

Code: Select all

$topic_data['topic_title'] = censor_text($topic_data['topic_title']);   &nbsp

ADD AFTER:

Code: Select all

// Make sure the tweet is no more than 140 chars.
if ($s_tweet)
{
    $strlen = strlen(htmlspecialchars(urlencode($topic_data['topic_title'] . ': ')) . $topic_url . ' ' . $hashtag);
    if ($strlen > 140)
    {
        $chars = 140 - strlen(': ' . $topic_url . ' ' . $hashtag);
        $tweet = truncate_string($topic_data['topic_title'], $chars, 255, true, '');
        $tweet .= ': ' . $topic_url . ' ' . $hashtag;
    }
    else
    
{
        $tweet = htmlspecialchars(urlencode($topic_data['topic_title'] . ' ')) . $topic_url . ' ' . $hashtag;
    }
}&
nbsp;  &nbsp


FIND:

Code: Select all

$template->assign_vars(array(   &nbsp

ADD AFTER:

Code: Select all

    'S_TWEET' => $s_tweet,
    'TWEET_TOPIC' => ($s_tweet) ? $tweet : '',   &nbsp


OPEN: includes/acp/acp_language.php
FIND:

Code: Select all

 'button_topic_new', 'button_topic_reply', 'button_issue_new'   &nbsp

IN-LINE ADD AFTER (add on the same line direct after that find):

Code: Select all

, 'button_tweet_topic'   &nbsp


OPEN: includes/acp/acp_styles.php
FIND:

Code: Select all

 'button_topic_new', 'button_topic_reply', 'button_issue_new'   &nbsp

IN-LINE ADD AFTER (add on the same line direct after that find):

Code: Select all

, 'button_tweet_topic'   &nbsp


OPEN: language/en/viewtopic.php
FIND:

Code: Select all

'TOTAL_VOTES'            => 'Total votes',   &nbsp

ADD AFTER:

Code: Select all

    'TWEET_TOPIC' => 'Tweet this topic',   &nbsp


OPEN: language/en/acp/styles.php
FIND:

Code: Select all

'IMG_BUTTON_TOPIC_REPLY'    => 'Reply topic',   &nbsp

ADD AFTER:

Code: Select all

    'IMG_BUTTON_TWEET_TOPIC'    => 'Tweet topic',   &nbsp


OPEN: styles/{your_style}/imageset/en/imageset.cfg
FIND:

Code: Select all

img_button_topic_reply = button_topic_reply.gif*25*96

ADD AFTER:

Code: Select all

img_button_tweet_topic = button_tweet_topic.gif*25*96
You need to change the file name and its dimensions if you don't use our buttons


OPEN: styles/{your_style}/template/viewtopic_body.html
FIND:

Code: Select all

      <div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->reply-icon<!-- ENDIF -->"><a href="{U_POST_REPLY_TOPIC}" title="<!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF -->"><span></span><!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED_SHORT}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF --></a></div>
   <!-- ENDIF -->

ADD AFTER:

Code: Select all

   <!-- IF not S_IS_BOT and S_TWEET --><div class="tweet-topic"><a href="http://twitter.com/home?status={TWEET_TOPIC}" title="{L_TWEET_TOPIC}"><span></span>{L_TWEET_TOPIC}</a></div><!-- ENDIF -->


OPEN: styles/{your_style}/theme/buttons.css
FIND:

Code: Select all

.reply-icon span   { background: transparent none 0 0 no-repeat; }

ADD AFTER:

Code: Select all

.tweet-topic span   { background: transparent none 0 0 no-repeat; }


FIND:

Code: Select all

.buttons div.reply-icon      { width: {IMG_BUTTON_TOPIC_REPLY_WIDTH}px; height: {IMG_BUTTON_TOPIC_REPLY_HEIGHT}px; }

ADD AFTER:

Code: Select all

.buttons div.tweet-topic      { width: {IMG_BUTTON_TWEET_TOPIC_WIDTH}px; height: {IMG_BUTTON_TWEET_TOPIC_HEIGHT}px; }


OPEN: styles/{your_style}/theme/colours.css
FIND:

Code: Select all

.reply-icon span   { background-image: url("{IMG_BUTTON_TOPIC_REPLY_SRC}"); }

ADD AFTER:

Code: Select all

.tweet-topic span   { background-image: url("{IMG_BUTTON_TWEET_TOPIC_SRC}"); }
You do not have the required permissions to view the files attached to this post.

User avatar
tumba25
Past Contributor
Past Contributor
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.

Tweet this post

Postby tumba25 » 01 Nov 2010, 00:04

This post contains edits for tweeting posts. You will also need the code from the first post.

OPEN: viewtopic.php
FIND:

Code: Select all

$postrow = array(&nbsp;&nbsp;&nbsp;&nbsp

ADD BEFORE:

Code: Select all

    // Make sure the tweet is no more than 140 chars.
    if ($s_tweet)
    {
        $post_url = $topic_url . '%23p' . $row['post_id'];
&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Remove&nbsp;search&nbsp;highlight&nbsp;span&nbsp;if&nbsp;post&nbsp;subject&nbsp;contains&nbsp;the&nbsp;search&nbsp;keyword.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$post_subject&nbsp;=&nbsp;str_replace(array('<span&nbsp;class="posthilit">',&nbsp;'</span>'),&nbsp;'',&nbsp;$row['post_subject']);
&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$post_subject&nbsp;=&nbsp;htmlspecialchars(urlencode($post_subject&nbsp;.&nbsp;':&nbsp;'));
        $strlen = strlen($post_subject . truncate_string($row['post_text'], 60, 255, true, '... ') . $post_url);
        if ($strlen > 140)
        {
            // Check that the post subject is not making this to long already.
            $strlen = strlen($post_subject . $post_url);
            if ($strlen > 140)
            {
                $chars = 140 - strlen(': ' . $post_url);
                $tweet = truncate_string($row['post_subject'], $chars, 255, true, '');
                $tweet .= ': ' . $post_url;
            }
            else
            
{
                $chars = 140 - strlen($post_subject . ': ' . $post_url);
                $tweet = truncate_string($row['post_text'], $chars, 255, true, '');
                $tweet = $post_subject . $tweet . ': ' . $post_url;
            }
        }
        else
        
{
            $tweet = $post_subject . truncate_string($row['post_text'], 60, 255, true, '... ') . $post_url;
        }
    }&nbsp;&nbsp;&nbsp;&nbsp

ADD AFTER:

Code: Select all

        'TWEET_POST' => ($s_tweet) ? $tweet : '',&nbsp;&nbsp;&nbsp;&nbsp


OPEN: includes/acp/acp_language.php
FIND:

Code: Select all

 'button_topic_new', 'button_topic_reply', 'button_issue_new'&nbsp;&nbsp;&nbsp;&nbsp

IN-LINE ADD AFTER (add on the same line direct after that find):

Code: Select all

, 'button_tweet_post'&nbsp;&nbsp;&nbsp;&nbsp


OPEN: includes/acp/acp_styles.php
FIND:

Code: Select all

 'button_topic_new', 'button_topic_reply', 'button_issue_new'&nbsp;&nbsp;&nbsp;&nbsp

IN-LINE ADD AFTER (add on the same line direct after that find):

Code: Select all

, 'button_tweet_post'&nbsp;&nbsp;&nbsp;&nbsp


OPEN: language/en/viewtopic.php
FIND:

Code: Select all

'TOTAL_VOTES'            => 'Total votes',&nbsp;&nbsp;&nbsp;&nbsp

ADD AFTER:

Code: Select all

    'TWEET_POST' => 'Tweet this post',&nbsp;&nbsp;&nbsp;&nbsp


OPEN: language/en/acp/styles.php
FIND:

Code: Select all

'IMG_BUTTON_TOPIC_REPLY'    => 'Reply topic',&nbsp;&nbsp;&nbsp;&nbsp

ADD AFTER:

Code: Select all

    'IMG_BUTTON_TWEET_POST'        => 'Tweet post',&nbsp;&nbsp;&nbsp;&nbsp


OPEN: styles/{your_style}/imageset/en/imageset.cfg
FIND:

Code: Select all

img_icon_post_quote = icon_post_quote.gif*20*54

ADD AFTER:

Code: Select all

img_button_tweet_post = button_tweet_post.gif*20*54
You need to change the file name and its dimensions if you don't use our buttons


OPEN: styles/{your_style}/template/viewtopic_body.html
FIND:

Code: Select all

<!-- IF postrow.U_INFO --><li class="info-icon"><a href="{postrow.U_INFO}" title="{L_INFORMATION}"><span>{L_INFORMATION}</span></a></li><!-- ENDIF -->

ADD AFTER:

Code: Select all

               <!-- IF not S_IS_BOT and S_TWEET --><li class="tweet-post"><a href="http://twitter.com/home?status={postrow.TWEET_POST}" title="{L_TWEET_POST}"><span>{L_TWEET_POST}</span></a></li><!-- ENDIF -->


OPEN: styles/{your_style}/theme/buttons.css
FIND:

Code: Select all

.quote-icon, .quote-icon a      { background: none top left no-repeat; }

ADD AFTER:

Code: Select all

.tweet-post, .tweet-post a      { background: none top left no-repeat; }


FIND:

Code: Select all

ul.profile-icons li.quote-icon   { width: {IMG_ICON_POST_QUOTE_WIDTH}px; height: {IMG_ICON_POST_QUOTE_HEIGHT}px; }

ADD AFTER:

Code: Select all

ul.profile-icons li.tweet-post   { width: {IMG_BUTTON_TWEET_POST_WIDTH}px; height: {IMG_BUTTON_TWEET_POST_HEIGHT}px; }


OPEN: styles/{your_style}/theme/colours.css
FIND:

Code: Select all

.quote-icon, .quote-icon a      { background-image: url("{IMG_ICON_POST_QUOTE_SRC}"); }

ADD AFTER:

Code: Select all

.tweet-post, .tweet-post a      { background-image: url("{IMG_BUTTON_TWEET_POST_SRC}"); }
You do not have the required permissions to view the files attached to this post.
Last edited by tumba25 on 13 Jan 2015, 00:00, edited 2 times in total.
Reason: Fixed bug.

Jaxo
Member
Member
Posts: 51
Joined: 30 Nov 2010, 22:42

Tweet this topic or post Mod

Postby Jaxo » 30 Nov 2010, 22:46

Hello all, i installed the Tweet this topic or post Mod. I have a question with a prob i cannot figure out.

The mod is installed and is working but not correctly,.. When i tweet some posts it works fine but with others it does not, .. it sends the wrong web address to twitter resulting it "the requested topic does not exist" when somebody clicks the link. here is an example of a link that did not work

on site:

Code: Select all

http://cccam-exchange.co.uk/viewtopic.php?f=146&p=3408#p3408

on twitter:

Code: Select all

http://cccam-exchange.co.uk/viewtopic.php?t=0 #phpBBModders


This appears to be happening on more threads then working ones :? :?

I have also noticed that the same think is happening on this site when i try to tweet a post/ thread, Any ideas whats wrong?

thanks in advance + thanks for the mod :beer:

User avatar
tumba25
Past Contributor
Past Contributor
Posts: 1058
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.

Re: Tweet this topic or post Mod

Postby tumba25 » 01 Dec 2010, 01:21

[url=http://phpbbmodders.net/board/viewtopic.php?f=118&t=6359]This[/url] would be to correct place to ask for support for that MOD.
First it seems like you have missed some edits since #phpBBModders are shown in your tweets. Can you tell us where on this site that happens?

Jaxo
Member
Member
Posts: 51
Joined: 30 Nov 2010, 22:42

Re: Tweet this topic or post Mod

Postby Jaxo » 01 Dec 2010, 09:32

sorry for posting in the wrong place, maybe someone could move the thread or would you like me to repost?

The mod was installed with automod and all file edits where correct accordining to it. I did have to do some manual edits also as I have a few different themes installed on the site however the problem is happening accross all my themes and not just the ones i did myself... It is also happening on this site when I try to tweet as a test so im thinking it may be a twittter issue more than anything else??

here is a few examples:

on my site the address is:

Code: Select all

http://cccam-exchange.co.uk/viewtopic.php?f=138&p=5800#p5800


when I tweet this page the address it put to twitter is:

Code: Select all

http://cccam-exchange.co.uk/viewtopic.php?t=0 #phpBBModders


and again on this page:

Code: Select all

http://cccam-exchange.co.uk/viewtopic.php?f=168&p=6688#p6688


it puts the link on twitter as:

Code: Select all

http://cccam-exchange.co.uk/viewtopic.php?t=0 #phpBBModders


Now for the strange thing, .... the same thing is also happening when I try to tweet something from this site. This very page for example

Code: Select all

http://phpbbmodders.net/board/viewtopic.php?f=23&t=6438&p=26745#p26745


appears on my twitter as

Code: Select all

http://phpbbmodders.net/board/viewtopic.php?t=6438 #phpBBModders


So I do not think there is anything wrong with my install as the same thing is happening when I try to tweet from this site, I think it is more an issue with the mod or else twitter. Any advice I am greatful for as I would really like to get this mod working. My twitter page is http://twitter.com/CCcamExchange.

I will leave a few incorrect tweets up so somebody can have a look.

Thanks :beer:

Jaxo
Member
Member
Posts: 51
Joined: 30 Nov 2010, 22:42

Re: Tweet this topic or post Mod

Postby Jaxo » 01 Dec 2010, 10:17

I am having a look around my site trying to fix this and think this line in viewtopic may be causing the prob

Code: Select all

$topic_url = generate_board_url() . '/viewtopic.' . $phpEx . '?t=' . $topic_id;


(im know nothing about code btw so this is only a guess) but it appears to me that the generate url is only generating the topic id, but when i look at my threads the also have an F= and P=, Not just T= and it appears to be these parts that is missing from my tweets, what would the F & P =?? is this forum id and post ID?

Its a stab in the dark here as I really dont know code :oops:

User avatar
bonelifer
Administrator
Administrator
Posts: 475
Joined: 24 Jun 2006, 17:48
Real name: William
Location: htpc.MythBuntu

Re: Tweet this topic or post Mod

Postby bonelifer » 01 Dec 2010, 23:37

Jaxo wrote:sorry for posting in the wrong place, maybe someone could move the thread or would you like me to repost?


Posts merged.

steve
Master of posting
Master of posting
Posts: 1213
Joined: 12 Jul 2009, 19:14
Location: uk

Re: Tweet this topic and/or post

Postby steve » 02 Dec 2010, 09:44

@ jaxo I tested this.

doesnt look like you changed this line as per instructed in the first post.

Code: Select all

    $hashtag = htmlspecialchars(urlencode('#phpBBModders'));

Change #phpBBModders to what ever you like.
Steve ©

z2z
New member
New member
Posts: 8
Joined: 12 Mar 2008, 06:48

Re: Tweet this topic and/or post

Postby z2z » 30 Apr 2011, 06:27

Looks great .. Subsilver version possible?

steve
Master of posting
Master of posting
Posts: 1213
Joined: 12 Jul 2009, 19:14
Location: uk

Re: Tweet this topic and/or post

Postby steve » 30 Apr 2011, 08:53

z2z wrote:Looks great .. Subsilver version possible?


Open: subsilver2/template/viewtopic_body.html

find:

Code: Select all

         <!-- IF S_DISPLAY_POST_INFO --><a href="{U_POST_NEW_TOPIC}">{POST_IMG}</a>&nbsp;<!-- ENDIF -->

before add:

Code: Select all

         <!-- IF S_TWEET --><a href="http://twitter.com/home?status={postrow.TWEET_POST}" title="{L_TWEET_POST}"><img src="{T_IMAGESET_LANG_PATH}/button_topic_tweet.gif" alt="{L_TWEET_POST}" /></a><!-- ENDIF -->      

find:

Code: Select all

         <!-- IF S_DISPLAY_POST_INFO --><a href="{U_POST_NEW_TOPIC}">{POST_IMG}</a>&nbsp;<!-- ENDIF -->

before add:

Code: Select all

         <!-- IF S_TWEET --><a href="http://twitter.com/home?status={postrow.TWEET_POST}" title="{L_TWEET_POST}"><img src="{T_IMAGESET_LANG_PATH}/button_topic_tweet.gif" alt="{L_TWEET_POST}" /></a><!-- ENDIF -->      

Upload this image to your subsilver2/imageset/en/ folder.

button_topic_tweet.gif

Refresh template and should be good to go :)
You do not have the required permissions to view the files attached to this post.
Steve ©

z2z
New member
New member
Posts: 8
Joined: 12 Mar 2008, 06:48

Re: Tweet this topic and/or post

Postby z2z » 03 May 2011, 07:31

thanks :D

Button is slightly mismatching .. [img]http://img121.imageshack.us/img121/6578/buttontopicnew.gif[/img] [img]http://img33.imageshack.us/img33/6519/buttontopicreplyn.gif[/img]

steve
Master of posting
Master of posting
Posts: 1213
Joined: 12 Jul 2009, 19:14
Location: uk

Re: Tweet this topic and/or post

Postby steve » 03 May 2011, 07:58

This ok,
button_topic_tweet.gif
You do not have the required permissions to view the files attached to this post.
Steve ©

z2z
New member
New member
Posts: 8
Joined: 12 Mar 2008, 06:48

Re: Tweet this topic and/or post

Postby z2z » 04 May 2011, 08:46

thanks & congrats buddy :beer:

Submitted http://phpbbmodders.net/tracker/55 related to this mod .. something to do url encode :?:


Return to “MOD Feedback”

Who is online

Users browsing this forum: CommonCrawl [Bot] and 0 guests