OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Facebook Open Graph protocol implementation

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.

Facebook Open Graph protocol implementation

Postby tobiascvanveen » Sun Jun 19, 2011 1:09 pm

hey folks,

I'd like to add Facebook's Open Graph protocol to the <meta> section of each page's <head>.
Details: https://developers.facebook.com/docs/opengraph/.

What need I modify to drop this in? Anyone else done this? Thanks!

Running OJS 2.2.3 with currently no hope of upgrade (tried; fails).

thanks /

tobias.
tobiascvanveen
 
Posts: 14
Joined: Sun Sep 12, 2010 1:33 pm

Re: Facebook Open Graph protocol implementation

Postby jmacgreg » Tue Jun 21, 2011 3:24 pm

Hi Tobias,

This looks pretty neat, actually. I'm guessing that you primarily want to have the like option show up in your articles, correct? There are a few ways you could do this. The easiest would be to simply manually add the meta code to the relevant template file -- for articles, that would be templates/article/header.tpl, for the main site header that would be templates/common/header.tpl (or lib/pkp/templates/common/header.tpl in OJS 2.3+).

You'll want to dynamically print relevant article information within the meta tags, as well, for example, abstract text in the "og:description" meta field, which you should be able to do by using the following Smarty variable:

Code: Select all
{$article->getLocalizedAbstract()|strip_unsafe_html|nl2br}


(That IIRC may not work in OJS 2.2.x -- let us know.)

Then you'll want to add the code for the Like button to one of the templates/article/... template files, depending on where you want it to show up. That should be fairly straightforward.

You could probably also do this as a system plugin. Take a look at some of the generic plugins and their code to get an idea on how to do this. For example, the generic/coins plugin and generic/googleAnalytics both add information to page footers. You can adapt these methods to add information to the page header.

If you have any specific questions, please let us know. If you do end up going the plugin route, we'd be happy to help; and also would be very happy if you were willing to share the plugin with the community.

One final note -- if you do manage to upgrade to a more recent version of OJS, you will find that there is now an "addThis" option available for journals, which allows for easy social sharing of articles online. See http://www.addthis.com/ for more information.

Cheers,
James
jmacgreg
 
Posts: 4191
Joined: Tue Feb 14, 2006 10:50 am


Return to OJS Development

Who is online

Users browsing this forum: Google [Bot] and 1 guest