Firefox PHP

Module: Social Media Sharing

Posted by rtetzloff 
All files from this thread

File Name File Size   Posted by Date  
social_share_1.png 39 KB open | download rtetzloff 08/15/2012 Read message
social_share_1.0.zip 9.7 KB open | download rtetzloff 08/15/2012 Read message
Module: Social Media Sharing
August 15, 2012 06:16AM
Hello,

Because I couldn't find anything that performed this function, I created a simple module that will share posts to social network sites. It is currently limited to Twitter, Facebook, and Google+. This module creates links on the post pages that allow you to share a post to the respective sites. It does NOT provide Like or +1 functionality, as I didn't really think this was particularly useful for this. I doubt that it's well written. I'm not really a programmer, but I've done a little with Phorum in the past, and I wanted to add this functionality to my phorum installation.

It does require adding a hook to the template, at least that's the only way I could figure out how to do what I wanted. You can use it to add social network links in individual posts or entire threads currently.

I'd like to create an easy way to manage the social networks that can be used and a way to add the links to the list pages. Perhaps someday I will make some changes to add these features. I don't spend a lot of time with this, so I can't see when or if that will be possible. If anyone wants to make changes to support these features, feel free to do so.

README:

Social Media Sharing Module

Instructions:

1. Install module into mods directory.
2. Make necessary changes to read.tpl, read_hybrid.tpl, and read_threads.tpl (Emerald based templates):

   read.tpl, read_hybrid.tpl
   -------------------------

** To create the social links in the individual message boxes next to the reply/quote buttons
   Find:
   {IF MESSAGES->URL->REPORT}<a class="icon icon-exclamation" href="{MESSAGES->URL->REPORT}">{LANG->Report}</a>{/IF}

   On a new line after this, add:
   {HOOK "social_share" MESSAGES}


** To create the social links for the entire topic near the print/follow/rss/moderator functions
   Find:
   {IF TOPIC->URL->MOVE}<a class="icon icon-move" href="{TOPIC->URL->MOVE}">{LANG->MoveThread}</a>{/IF}
   {/IF}

   On a new line after this, add:
   {HOOK "social_share" TOPIC}

   read_threads.tpl
   -------------------------

** To create the social links in the individual message boxes next to the reply/quote buttons
   Find:
   {IF MESSAGE->URL->REPORT}<a class="icon icon-exclamation" href="{MESSAGE->URL->REPORT}">{LANG->Report}</a>{/IF}

   On a new line after this, add:
   {HOOK "social_share" MESSAGE}


** To create the social links for the entire topic near the print/follow/rss/moderator functions
   Find:
   {IF URL->FEED}
        <a class="icon icon-feed" href="{URL->FEED}">{FEED}</a>
   {/IF}

   On a new line after this, add:
   {HOOK "social_share" TOPIC}

3. For Facebook and Google+ sharing, I recommend selecting a site image that is reasonably sized 
   and adding it to phorum_directory/images. Then add the following line to Phorum Head Tags in 
   General settings:

   <link rel="image_src" href="[www.domain.name]; />

   This will cause Facebook and Google+ to use that image for posts.
4. Configure options.
5. Enable module.

Adding social networks is not a trivial task at the moment. I'd like to include a much easier way 
to do so in the future, but I don't know if time will permit it.

Changelog:
----------

2012-08-14	v1.0

-Original version created by Ray Tetzloff




Attachments:
open | download - social_share_1.0.zip (9.7 KB)
Re: Module: Social Media Sharing
August 16, 2012 04:38PM
Great work, thanks for sharing your module!


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: Social Media Sharing
November 05, 2012 09:30PM
I installed this module, but instead of individual posts, I always get a link (in facebook) to the entire topic.

I validated my changes on read.tpl, and I´m sure I added this: {HOOK "social_share" MESSAGES} on the right place, but still, I get the entire topic.

Any help will be really appreciated.
Re: Module: Social Media Sharing
November 06, 2012 09:37AM
Well, there is no link to a single message if the forum read view is set to flat.


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting
Re: Module: Social Media Sharing
January 01, 2013 07:47PM
Using the Social Media Sharing module and the Smileys module together causes problems whenever Smileys are used on the subject line for me. Having a smiley in the subject line breaks the Twitter link generated by the Social Media Sharing module. Can anyone assist with fixing?
al
Re: Module: Social Media Sharing
January 16, 2013 06:58PM
I changed a little mod for Twitter could be someone like
file social_share.php
$subject = $message['subject']; replace $subject = $message['body'];
further add strings =>

$subject=iconv("WINDOWS-1251","utf-8",$subject); // instead of WINDOWS-1251 set the code page that you have chosen for your forum
$tweet = strip_tags($subject);
if (strlen($tweet)>140)
{
$tweet=substr($tweet, 0, 136).' ...';
}

further =>
Language: PHP
print "<a class=\"icon icon-share-twitter\" href=\"http://twitter.com/intent/tweet?source=sharethiscom&text=".$subject."&url=".$url."\"";

replace
Language: PHP
print "<a class=\"icon icon-share-twitter\" href=\"http://twitter.com/intent/tweet?source=sharethiscom&text=".$tweet."&url=".$url."\"";


This allows you to Tweet concrete post, using a flat list. I still work on it.



Edited 1 time(s). Last edit at 01/16/2013 07:02PM by al.
al
Re: Module: Social Media Sharing
January 17, 2013 12:59PM
I got such a file social_share.php:



Language: PHP
<?php   if(!defined("PHORUM")) return;   function social_share_mod_css_register($data) {   $data[';register';][] = array( ';module'; => ';social_share';, ';where'; => ';after';, ';source'; => ';file(mods/social_share/social_share.css)'; ); return $data; }   function social_share_mod_thread($message) {   global $PHORUM; // Format the read URL. $url = phorum_get_url( PHORUM_FOREIGN_READ_URL, $message[';forum_id';], $message[';thread';], $message[';message_id';] );   // Strip auth data from the URL, if availble. if (isset($_POST[PHORUM_SESSION_LONG_TERM])) { $url = preg_replace( ';!,?'; . PHORUM_SESSION_LONG_TERM.';='; . urlencode($_POST[PHORUM_SESSION_LONG_TERM]).';!';, ';';, $url ); }   $url=urlencode($url); $thread = $message[';subject';]; $body = $message[';body';]; $tweet = strip_tags($body); $facebook = "';&t=';.$tweet"; if (strlen($facebook)>300) { $facebook=substr($tweet, 0, 300).'; ...';; }   if (strlen($tweet)>140) { $tweet=substr($tweet, 0, 136).'; ...';; }   $facebook=iconv("WINDOWS-1251","utf-8",$facebook); $tweet=iconv("WINDOWS-1251","utf-8",$tweet);   if ( $PHORUM[';social_share';][';share_twitter';] == 1 ) { print "<a class=\"icon icon-share-twitter\" href=\"http://twitter.com/intent/tweet?source=sharethiscom&text=".$tweet."&url=".$url."\""; if ( $PHORUM[';social_share';][';link_new_window';] == 1 ) print " target=\"_blank\""; print ">Tweet</a>"; }   if ( $PHORUM[';social_share';][';share_facebook';] == 1 ) { print "<a class=\"icon icon-share-facebook\" href=\"https://www.facebook.com/sharer.php?u=".$url.$facebook."\""; if ( $PHORUM[';social_share';][';link_new_window';] == 1 ) print " target=\"_blank\""; print ">Facebook</a>"; }   if ( $PHORUM[';social_share';][';share_google-plus';] == 1 ) { print "<a class=\"icon icon-share-google-plus\" href=\"https://plus.google.com/share?url=".$url."\""; if ( $PHORUM[';social_share';][';link_new_window';] == 1 ) print " target=\"_blank\""; print ">Google+</a>"; }     } ?>






Not a lot of changes. Works as I need. Unfortunately the output to Google+ looks bad. Google+ does not support the transfer of the post in the link, as facebook or twitter. Google+ so I disconnect to the admin.
What happened and how it works can be found here. [www.vanderboot.ru] May be useful to someone :)



Edited 1 time(s). Last edit at 01/17/2013 01:05PM by al.
Re: Module: Social Media Sharing
March 21, 2013 04:28AM
I installed this mod on my site and it doesnt show up.
[www.bannedlikeproductions.com]

Yes i turned it on in the ACP but the buttons are not showing.



Edited 1 time(s). Last edit at 03/21/2013 04:29AM by White_Rabbit.
Re: Module: Social Media Sharing
March 21, 2013 08:10AM
Did you follow the readme?


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting
Re: Module: Social Media Sharing
March 25, 2013 12:36PM
How did this happen?
[www.bannedlikeproductions.com]

The twitter link is all messed up but only pops up in a few threads?
Sorry, only registered users may post in this forum.

Click here to login