Display social media icons in every post.

Started by verystrong, March 19, 2016, 10:27:41 PM

Previous topic - Next topic

verystrong

I would like to seek for your help regarding putting a social media icons to display in every post in a topic.

I have done this with third party framework (ShareThis) but it only share the topic not every post.

Please see screenshot that I want to display.



Thank you for your help.







Pipke

go to file ../Themes/{your_theme}/Display.template.php

Code (find) Select

if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
echo '
</ul>';

echo '
</div>';


Code (replace by) Select

if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
echo '
</ul>';

echo '
                <ul style="list-style-type: none;">
      <li><a href="link_to_your_social_media_page1"><img src="url_to_your_social_media_icon1" alt"" width="32" height="32" /></a></li>
                      <li><a href="link_to_your_social_media_page2"><img src="url_to_your_social_media_icon2" alt"" width="32" height="32" /></a></li>
                      <li><a href="link_to_your_social_media_page3"><img src="url_to_your_social_media_icon3" alt"" width="32" height="32" /></a></li>
</ul>
</div>';
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Kindred

pipke, that won't do what the user has asked...

verystrong....

why? SMF links to the THREAD and displays the THREAD (with the posts)

http://custom.simplemachines.org/mods/index.php?mod=2111

this can SHOW the sharethis in every post...  but it still shares the thread link.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Pipke

Quote from: Kindred on March 20, 2016, 07:09:16 AM
pipke, that won't do what the user has asked...

crap, i misread the ops request i thought only media icons and that it was not ment to be shared. The mod you posted should do the job.
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

verystrong

Quote from: Kindred on March 20, 2016, 07:09:16 AM
pipke, that won't do what the user has asked...

verystrong....

why? SMF links to the THREAD and displays the THREAD (with the posts)

http://custom.simplemachines.org/mods/index.php?mod=2111

this can SHOW the sharethis in every post...  but it still shares the thread link.

I have tried this mod but i shares only thread topic.

Quote from: Pipke on March 20, 2016, 04:59:38 AM
go to file ../Themes/{your_theme}/Display.template.php

Code (find) Select

if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
echo '
</ul>';

echo '
</div>';


Code (replace by) Select

if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
echo '
</ul>';

echo '
                <ul style="list-style-type: none;">
      <li><a href="link_to_your_social_media_page1"><img src="url_to_your_social_media_icon1" alt"" width="32" height="32" /></a></li>
                      <li><a href="link_to_your_social_media_page2"><img src="url_to_your_social_media_icon2" alt"" width="32" height="32" /></a></li>
                      <li><a href="link_to_your_social_media_page3"><img src="url_to_your_social_media_icon3" alt"" width="32" height="32" /></a></li>
</ul>
</div>';


I have tried your code works perfectly. However, When I shared it to facebook it appears the domain name instead of subject/topic.
and also that when i shared the second post and clicked the shared link on facebook it was not jump to the specific post.







echo '
<ul  class="reset smalltext quickbuttons">
<li><a href="https://www.facebook.com/sharer/sharer.php?u=',$message['href'],'">
<img src="images/socialnetworking/img/facebook-16.png" alt="" width="16" height="16"></a></li>
</ul>
</div>';

Kindred

Yes, as I said, pipke's code will not do what you want.

Also, as I said. If think you are goign about the this wrong way... Because smf does not ever present the post as a separate content. Everything is part of a thread....   A post alone has very little value. Threads are the point of value for forums, hence the fact that all of the mods will focus on linking the thread.

Why do you think that the post is more important than the thread, since the thread contains the post and the thread is the entire conversation, not just the post, out of context?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Wellwisher

#6
I made an open-source social share mod for giggles and attached it to this message, try it. It basically adds Social Share buttons (Facebook, twitter, GooglePlus) to Topics And Posts.

Demo:



I asked the same question a long time ago here. Sadly, at that time, there was nothing that appealed to me but thankfully with the help of @Paracelsus, I figured it out. I was going to write a set of instructions for you to manually edit files... but I figured, that's as easy as writing this mod so I saved you (and possibly others) some time. Works for default theme. If people want to add this mod to their custom themes, it will require minior css tweaks.



(Sign in to download this attachment)

Kindred

but - does it share the POST or does it share the thread URL?

The OP is not asking for just the icons to be added to the posts -- the sharethis mod already does that (and supports several dozen social sites)
What the OP wants (even though he doesn't seem to understand the pointlessness of it) is to share the individual POST - not the thread.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Wellwisher

Quote from: Kindred on March 21, 2016, 03:16:05 PM
but - does it share the POST or does it share the thread URL?

The OP is not asking for just the icons to be added to the posts -- the sharethis mod already does that (and supports several dozen social sites)
What the OP wants (even though he doesn't seem to understand the pointlessness of it) is to share the individual POST - not the thread.

It does share individual posts.

If you have tons of posts on a single page and you want to share one post... I don't understand why this would be pointless. It's a very useful feature. I know a few large forums like Paracelsus's site and other commerical forums that have this feature for their visitors convenience.

Paracelsus

Quote from: Kindred on March 21, 2016, 03:16:05 PM
but - does it share the POST or does it share the thread URL?

The OP is not asking for just the icons to be added to the posts -- the sharethis mod already does that (and supports several dozen social sites)
What the OP wants (even though he doesn't seem to understand the pointlessness of it) is to share the individual POST - not the thread.


It shares posts.

Wellwisher's code was inspired on my dirty quick solution that I've implemented on our forum (thanks for the mention Wellwisher ;)) and it works flawlessly with individual post sharing.


Edit: And I agree it is quite useful, sometimes people wish to point out a certain post and not the entire topic which can have hundreds or thousands of pages and uninteresting posts.

Wellwisher

Quote from: Paracelsus on March 21, 2016, 04:29:45 PM
Wellwisher's code was inspired on my dirty quick solution that I've implemented on our forum (thanks for the mention Wellwisher ;))

No worries mate your name is also credited inside the mod files, I still think your forum is one of the best looking ones out there, really showcase worthy. When I first saw forumscp, I had trouble coming to terms with that SMF was running it. The design, responsive theme, menu and social features (including the social shares counters) really blew me away. Really opened my eyes to what SMF was capable of. Again thank you for helping me out with this from a long time ago. I pass on your wisdom!  :P

verystrong

Quote from: Wellwisher on March 21, 2016, 02:49:26 PM
I made an open-source social share mod for giggles and attached it to this message, try it. It basically adds Social Share buttons (Facebook, twitter, GooglePlus) to Topics And Posts.

Demo:



I asked the same question a long time ago here. Sadly, at that time, there was nothing that appealed to me but thankfully with the help of @Paracelsus, I figured it out. I was going to write a set of instructions for you to manually edit files... but I figured, that's as easy as writing this mod so I saved you (and possibly others) some time. Works for default theme. If people want to add this mod to their custom themes, it will require minior css tweaks.



(Sign in to download this attachment)

Wow great!, This is what i am looking for.

Thanks

nsno

excellent work, looks good and I've been wanting the ability to quickly share individual posts in threads so this is brilliant, thanks!

Wellwisher

Quote from: nsno on March 25, 2016, 07:15:16 AM
excellent work, looks good and I've been wanting the ability to quickly share individual posts in threads so this is brilliant, thanks!

Looks pretty sweet on your forum. If you want to tweak and make some esthetics adjustments for your custom theme:

1. In your forum index.css line 5019 look for:

.share {
    float: right;
    list-style: outside none none;
    margin: 2px 0 0;
    padding: 0 11px 0 0;
    text-align: center;
}


Replace "margin: 2px 0 0;" with:

margin: 0px;

2. In your forum index.css line 5029 look for:

.share button {
  background-color: #5a6c85;
  border: medium none !important;
  border-radius: 5px;
  color: #fff;
  padding: 5px;
}


replace with:

.share button {
  background-color: #5a6c85;
  border: medium none !important;
  border-radius: 5px;
  color: #fff;
  padding: 5px;
cursor: pointer;
}


Wellwisher

The mod also adds font-awesome & jquery in your theme index.template.php and if you already have them, just remove the ones this mod adds in your theme index.template.php:


<!-- Enter SocialShareTopicsAndPosts -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- End SocialShareTopicsAndPosts -->


@nsno in your case, I would remove the share mods Jquery 1.11.3 since you already have the latest version in your theme.

nsno

Quote from: Wellwisher on March 25, 2016, 08:29:25 AM
The mod also adds font-awesome & jquery in your theme index.template.php and if you already have them, just remove the ones this mod adds in your theme index.template.php:


<!-- Enter SocialShareTopicsAndPosts -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- End SocialShareTopicsAndPosts -->


@nsno in your case, I would remove the share mods Jquery 1.11.3 since you already have the latest version in your theme.

brilliant thank you!

Biology Forums

Nice implementation,  HOWEVER, keep in mind that if the icons are displayed without a hidden div, shares actually increase. I know it sounds weird, but this is from experience. I guess ppl don't like to be a treasure hunter when it comes to sharing... also why services like addthis are so popular, they are in-your-face, for the complusive sharers

Wellwisher

Quote from: Shuban on March 26, 2016, 04:39:08 PM
Nice implementation,  HOWEVER, keep in mind that if the icons are displayed without a hidden div, shares actually increase. I know it sounds weird, but this is from experience. I guess ppl don't like to be a treasure hunter when it comes to sharing... also why services like addthis are so popular, they are in-your-face, for the complusive sharers

This will not "duplicate" or increase social shares (one can sure wish though, right?).  If it did that, me and Paracelsus would sell it and split the earnings and live on our own private Islands. ;D It's a simple solution which also funtions on mobile devices/ tablets. My members and visitors have used @Paracelsus code snippit for almost a year and love it. Paracelsus has used it on his much larger forum for atleast double that time. Also before I installed it on my forum, I tested it for a number of weeks. It will only register "one-click" and open one social share window, where users will submit their desired post link.

AddThis solution is also brillant but for my purposes it was an over-kill. I wanted something simple without the overwhelming options/ bulky script and one which only catered to main social contenders.

nsno

Quote from: Wellwisher on March 27, 2016, 01:56:53 AM
Quote from: Shuban on March 26, 2016, 04:39:08 PM
Nice implementation,  HOWEVER, keep in mind that if the icons are displayed without a hidden div, shares actually increase. I know it sounds weird, but this is from experience. I guess ppl don't like to be a treasure hunter when it comes to sharing... also why services like addthis are so popular, they are in-your-face, for the complusive sharers

This will not "duplicate" or increase social shares (one can sure wish though, right?).  If it did that, me and Paracelsus would sell it and split the earnings and live on our own private Islands. ;D It's a simple solution which also funtions on mobile devices/ tablets. My members and visitors have used @Paracelsus code snippit for almost a year and love it. Paracelsus has used it on his much larger forum for atleast double that time. Also before I installed it on my forum, I tested it for a number of weeks. It will only register "one-click" and open one social share window, where users will submit their desired post link.

AddThis solution is also brillant but for my purposes it was an over-kill. I wanted something simple without the overwhelming options/ bulky script and one which only catered to main social contenders.

I think what Shuban meant was that if the icons are more visible, users are more likely to click them

there is a fine balance though between cluttering your forum with icons for everything, and providing a feature which - if wanted - is easily found

this solution stays on the right side of the line for me.  if people want to share a post, they can see the word "Share" and click it.  I don't want every post to have a load of sharing buttons for different social networks all on display.

Nory

#19
Hello,

Work perfectly with latest SMF version.

Advertisement: