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 12:16AM |
Registered: 14 years ago Posts: 13 |
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.
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
August 16, 2012 10:38AM |
Admin Registered: 17 years ago Posts: 8,532 |
Great work, thanks for sharing your module!
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Maurice Makaay
Phorum Development Team



Re: Module: Social Media Sharing November 05, 2012 03:30PM |
Registered: 9 years ago Posts: 11 |
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.
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 03:37AM |
Admin Registered: 19 years ago Posts: 9,240 |
Re: Module: Social Media Sharing January 01, 2013 01:47PM |
Registered: 9 years ago Posts: 34 |
Re: Module: Social Media Sharing January 16, 2013 12:58PM |
Registered: 9 years ago Posts: 2 |
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 =>
replace
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 01:02PM by al.
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: PHPprint "<a class=\"icon icon-share-twitter\" href=\"http://twitter.com/intent/tweet?source=sharethiscom&text=".$subject."&url=".$url."\"";
replace
Language: PHPprint "<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 01:02PM by al.
Re: Module: Social Media Sharing January 17, 2013 06:59AM |
Registered: 9 years ago Posts: 2 |
I got such a file social_share.php:
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 07:05AM by al.
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 07:05AM by al.
March 20, 2013 11:28PM |
Registered: 9 years ago Posts: 20 |
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/20/2013 11:29PM by White_Rabbit.
[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/20/2013 11:29PM by White_Rabbit.
Re: Module: Social Media Sharing March 21, 2013 03:10AM |
Admin Registered: 19 years ago Posts: 9,240 |
March 25, 2013 07:36AM |
Registered: 9 years ago Posts: 20 |
How did this happen?
[www.bannedlikeproductions.com]
The twitter link is all messed up but only pops up in a few threads?
[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.