[OJS] Share this (Social Media)

Hello,

I’m using OJS 2.4.4.1 and was looking for a social media share widget for the sidebar. I’m surprised this isn’t default or that none exist, unless my searching is subpar?

I tried using sharethis.com and copying the code into the custom block plugin, but that didn’t work as it strips out the html and I don’t know where to place the script code that is suppose to go in the head.

Any suggestions on how to add standard facebook, twitter, G+, etc icons so users can share articles on their social media pages?

Thank you

Hi @mbauerCOM,

I haven’t tested this myself, but you ought to be able to put arbitrary HTML into the custom block – just make sure you go into HTML mode in the TinyMCE control and paste the code there.

Generally speaking, there’s some guidance on social media in the Customizing OJS section of the wiki: https://pkp.sfu.ca/wiki/index.php/Customizing_OJS#Adding_social_media_icons_to_a_custom_block

Regards,
Alec Smecher
Public Knowledge Project Team

Yeah adding follow buttons is fairly easy and straightforward. It’s the share that’s a little more tricky because it involves scripts and checking to see if the user is logged in to their own social media or not. I would like to give users the ability to share links to our articles on their own social media with just a click.

I found a sharethis.com competitor called addthis.com that uses a simpler HTML that the custom block didn’t reject. But it also calls for adding a script to the body tag.

`

`

Where should I add that do you think?

1 Like

Hi @mbauerCOM,

AddThis is already supported in OJS – see the Reading Tools configuration area as Journal Manager.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Ah brilliant, I apologize for missing that. I figured it would be way too demanded to be left out.

Thank you!

How to use AddThis plugin for OJS 3.x?

Hi @hannanhazari,

Where would you like to add the sharing tools?

Regards,
Alec Smecher
Public Knowledge Project Team

Thanks Alec for prompt reply.
I would like to have two components i.e. Firstly, Follow us social media buttons on landing (home) page and other static pages. Secondly, Share social media buttons on Current issue, Archives, and individual articles page.
Your help in this regard is appreciated.

Hi @hannanhazari,

On static pages (and I believe also the homepage), you can enter the
ShareThis markup into the setup fields to have it display there. For the
issue and article pages, your best bet is probably to edit the template
files and insert it there. Note that you’ll probably need to use the
Smarty {literal} tags when editing templates to avoid accidental interpretation of { and } characters; see the Smarty documentation for more information.

Regards,
Alec Smecher
Public Knowledge Project Team

Could you provide more detailed instructions on how to connect AddThis plug-in (OJS 3.0.2) to article pages by means of template editing? Which code should I add to the template?

At the moment addThis is hooked to Templates::Article::Details, in the default theme that is basically the right sidebar on the article page where you will also see for example the “How to cite” block.

Well, let’s go step by step :frowning:

1.AddThis plug-in installed at /plugins/generic/addThis-master/

2.I see the following entries in the article_details.tpl (/templates/frontend/objects/):

*Core components are produced manually below, but can also be added via plugins using the hooks provided:
*Templates::Article::Main
*Templates::Article::Details

and {call_hook name=“Templates::Article::Details”}

3.What should I add to the template to “activate” AddThis hook?

Hi,

The folder of the plugin should be just “addThis”. Remove “-master”.

After that, just enable the plugin and the buttons should show on the article page, in the bottom of the sidebar.

OK, thanks!

The problem was in the folder name. Now it works!

One more remark. We are using https for OJS. Thus AddThis plugin causes a warning in Google Chrome about unsafe scripts. So I just edit addThis.tpl changing script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js to src="https://s7.addthis.com/js/250/addthis_widget.js. No warnings anymore.

Ok, I made a pull request for @asmecher about that: fix http protocol to https in template url's by ajnyga · Pull Request #1 · pkp/addThis · GitHub

1 Like

Hello everyone!

I’ve tried adding addthis to our OJS, but we did not get it.

After activating the addthis module nothing appears on the page. What I can be doing wrong?

This is the site: http://iberoamericasocial.com/ojs/index.php/IS/article/view/187

A hug and thank you very much! And sorry for my english!

Hi @jmbarroso,

Can you describe how you installed the plugin?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher

I uploaded it by ftp in plugins/generic/addThis.

Then I activated it inside the journal manager. But it does not appear anywhere.

Hugs.

Hi @jmbarroso,

That won’t fully install the plugin. Try removing it e.g. via FTP, and then download the .tar.gz file from the Releases area, and upload it via the Plugins tab of the journal settings.

Regards,
Alec Smecher
Public Knowledge Project Team

Dear @asmecher

I have deleted the plugin by ftp, but when I try to install the plugin through the tab, the system tells me that “The uploaded file does not contain a folder that corresponds to the plugin name”

Do you know why that can be?

Thank you very much and a hug.