• This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Tweet Per-Post

Onimua

Well-known member
This guide will let you put a Twitter button beside each post, allowing you to link to specific posts within a thread instead of the entire thread, or put a link to tweet beneath each post, whichever you prefer.

Displaying Tweet Link Beside a Post

Copy this code:
HTML:
<xen:if is="{$xenOptions.tweet.enabled}">
<xen:if is="{$controllerName} == 'XenForo_ControllerPublic_Thread'">
    <div class="tweet shareControl">
        <a href="http://twitter.com/share" class="twitter-share-button"
            data-count="horizontal"
            data-lang="{xen:helper twitterLang, $visitorLanguage.language_code}"
            data-url="{xen:link canonical:posts, {$post}}"
            {xen:if {$thread.title}, 'data-text="{$thread.title}"'}
            {xen:if {$xenOptions.tweet.via}, 'data-via="{$xenOptions.tweet.via}"'}
            {xen:if {$xenOptions.tweet.related}, 'data-related="{$xenOptions.tweet.related}"'}>{xen:phrase tweet}</a>
    </div>
</xen:if>
</xen:if>

Go to your message_user_info template and look for this at the bottom:

HTML:
    <span class="arrow"><span></span></span>
</div>
CODE GOES HERE
</div>

Between the two </div> tags, past the code you copied before and save the template.

The last thing is to go into EXTRA.css and paste the following code in there as well:

HTML:
.messageUserInfo .tweet { margin-top: 10px; }

The end result looks like this:

under_avatar.webp

Displaying Tweet Link Under a Post

Alternatively, if you want to make a Tweet link to match the other links below the message, copy this code:

HTML:
<xen:if is="{$xenOptions.tweet.enabled}">
<xen:if is="{$controllerName} == 'XenForo_ControllerPublic_Thread'"><a href="http://twitter.com/share?url={xen:link canonical:posts, {$post}}" target="_blank" class="item control tweet">{xen:phrase tweet}</a></xen:if>
</xen:if>

Then go to post template. Find this section:

HTML:
<div class="publicControls">
                <a href="{xen:link threads/post-permalink, $thread, 'post={$post}'}" class="item muted postNumber hashPermalink" title="{xen:phrase permalink}">#{xen:calc '{$post.position} + 1'}</a>
                <xen:if is="{$post.canLike}">
                    <a href="{xen:link posts/like, $post}" class="LikeLink item control {xen:if $post.like_date, unlike, like}" data-container="#likes-post-{$post.post_id}"><span></span><span class="LikeLabel">{xen:if $post.like_date, {xen:phrase unlike}, {xen:phrase like}}</span></a>
                </xen:if>
                <xen:if is="{$canReply}">
                    <a href="{xen:link threads/reply, $thread, 'quote={$post.post_id}'}" data-postUrl="{xen:link posts/quote, $post}" class="ReplyQuote item control reply" title="{xen:phrase reply_quoting_this_message}"><span></span>{xen:phrase reply}</a>
                </xen:if>

                CODE HERE
            </div>

Right before the closing </div>, paste the code you just copied.

The end result looks like this:

tweet_link.webp

You can put the link wherever you want in the section of course, just look at the surrounding HTML and place it where you want. :)

Thanks to King Kovifor for pointing something out and OperaManiac for the lead on being able to make the link-only option.
 
OK, easy as all get-out to install, excellent!

The only issue is, after installation, there is a 1 in the box on all posts, lol.
 
OK, easy as all get-out to install, excellent!

The only issue is, after installation, there is a 1 in the box on all posts, lol.
Ah, seems there might be a complication with the thread itself that I didn't think about. Let me see if there's something I can do... :unsure:
 
ah I see what you're saying. If the thread's been tweeted, then there's going to be a 1 by each of the posts.
I can understand the logic behind that actually.

However when I tweeted the one post, the other posts did stay at 1 while the post I tweeted went to 2.
I don't know about anyone else, but I'm ok with that.
 
ah I see what you're saying. If the thread's been tweeted, then there's going to be a 1 by each of the posts.
I can understand the logic behind that actually.

However when I tweeted the one post, the other posts did stay at 1 while the post I tweeted went to 2.
I don't know about anyone else, but I'm ok with that.
Go back and use the new code I put (it's really a one-line change) and tell me how that works.
 
Go back and use the new code I put (it's really a one-line change) and tell me how that works.

It worked, and it's AWESOME!!!

Thanks so much for taking the time out of your blog coding to do this add-on.
Fantastic!

And thanks KK for whatever assistance you gave Onimua. :p
 
I thanked him too. Now off you go back to your blog.

I just love XenForo and its group of helpful members, coders, etc!
 
Hi Onimua,

Thank you for this, it works really well :) I've one small problem, I just noticed that this adds the tweet option to private conversations too which could be a bit dodgy in the hands of a trouble-maker.

Is there a way to prevent this bit?

Regards,
Renada :)
 
Hi Onimua,

Thank you for this, it works really well :) I've one small problem, I just noticed that this adds the tweet option to private conversations too which could be a bit dodgy in the hands of a trouble-maker.

Is there a way to prevent this bit?

Regards,
Renada :)

:confused:

Yes, there is a way... give me a bit of time.
 
Top Bottom