OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Viewing metadata into article.tpl

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

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

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Viewing metadata into article.tpl

Postby karnova » Mon Sep 03, 2012 6:29 pm

Hi,

I would like to view metadata (such as page number, ISSN, submission date, accepted date, and edited date) of an article in the article page ( I assume I should do something with article.tpl). I'm not really good in php, I would appreciate if anyone could help me with some lines of code that I need to add.
Thanks
karnova
 
Posts: 7
Joined: Mon Sep 03, 2012 6:19 pm

Re: Viewing metadata into article.tpl

Postby springday » Thu Sep 06, 2012 1:00 am

Hi Karnova,

you're right about the location where to apply your changes: You can edit /templates/article/article.tpl to achieve your goal. I have also added the DOI to our article view pages and achieved this with the following code:

Code: Select all
{if $article->getStoredDOI()}
      <div id="articleDOI">
         <h4>{translate key="rt.metadata.pkp.doi"}</h4>
         <br/>
         <div>DOI: {$article->getStoredDOI()|escape}</div>
         <br/>
      </div>
   {/if}


For the other info you want to retrieve, you can exchange the two occurances of "$article->getStoredDOI()" to "$article->getDateSubmitted()" (submission date), "$article->getLastModified()" (date of last modification), or $article->getDatePublished(). However, it seems the DOI handling has changed now in OJS 2.4, so if you have already upgraded your OJS installation, the above code for DOI won't work anymore. If you're still at OJS 2.3.7 or below, it should give you the desired effect.

Best wishes,
Kai
springday
 
Posts: 111
Joined: Wed Jul 25, 2012 2:56 pm
Location: Munich, Germany

Re: Viewing metadata into article.tpl

Postby springday » Thu Sep 06, 2012 4:14 am

Hi Karnova,

I have just had a closer look at the new version OJS 2.4. In this version the article pages automatically display the DOI (or other public identifiers), so you won't need to change anything. If you want to add the date information you asked for, you could still go with the code fragment I posted and do some adjustments to your needs. Are you familiar with the way locale files work in OJS? Do you know how you could adjust a line like <h4>{translate key="XXXX"}</h4> to do something useful for you? If you need further details and cannot find enough information in the OJS Technical Reference, just ask for more here.

Best wishes,
Kai
springday
 
Posts: 111
Joined: Wed Jul 25, 2012 2:56 pm
Location: Munich, Germany

Re: Viewing metadata into article.tpl

Postby karnova » Sun Sep 09, 2012 6:58 pm

Hi Kai,


Thanks for the code. I managed to add submission date and last modiying date. Would you please explain more about the translate key (probably specific to the metadata that I'm working now, i.e. submission date and accepting date). I have another questions:
1. Where can I find the list of functions apply for $article?
2. Where can I find the list of translate key (metadata.pkp.....)?

Karnova
karnova
 
Posts: 7
Joined: Mon Sep 03, 2012 6:19 pm

Re: Viewing metadata into article.tpl

Postby springday » Sun Sep 09, 2012 11:36 pm

Hi Karnova,

first I must warn you: I'm not an OJS developer, but a user just like you. So take my words with a grain of salt - I could be wrong or overlooking something.

First, the functions that are defined for $article are in three places. $article is an instance of the class PublishedArticle, which you will find in /classes/article/PublishedArticle.inc.php. Every PublishedArticle is also an Article, so it inherits all the functions from /classes/article/Article.inc.php. And every Article also is a Submission, so the functions of the class Submission are also applicable to $article. The code for the Submission class is in /lib/pkp/classes/submission/Submission.inc.php.

Secondly: Unfortunately there's not one list of all translate keys. They're spread over many files in many different locations. The most import are all the XML files in the subfolders of /locale and /lib/pkp/locale. Every plugin has its own locale files, so there are translate key definitions in the plugin folders, too.
You can simply add a new locale key by following the pattern that you'll see in those files, for example in /locale/en_US/locale.xml:

Code: Select all
<message key="navigation.categories">Categories</message>


The value after "key" is the one you can call through your template's {translate key=XXX} function. It will return the text in the message element, e.g. "Categories" and use that to display on your website. So, if you add a new line like this:

Code: Select all
<message key="article.submissionDate">Submission Date</message>


in the en_US folder or

Code: Select all
<message key="article.submissionDate">Datum podání</message>


in the cs_CZ folder, etc., the program will choose the appropriate words for displaying, according to the locale chosen by you and/or the user of your website, when {translate key="article.submissionDate"} will be called in the template.
Also note that there is a tool for working with the locale keys available for journal managers. In the journal management, go to Plugins, then click on "Generic Plugins" and then choose / activate the "Translation plugin" in this list. This will allow you to edit the existing localization key/value-pairs.
springday
 
Posts: 111
Joined: Wed Jul 25, 2012 2:56 pm
Location: Munich, Germany

Re: Viewing metadata into article.tpl

Postby springday » Sun Sep 09, 2012 11:41 pm

P.S.: check the locale keys in this file: /lib/pkp/locale/en_US/submissions.xml. Maybe some of those key will be useful for your purpose of displaying article information?

Regards,
Kai
springday
 
Posts: 111
Joined: Wed Jul 25, 2012 2:56 pm
Location: Munich, Germany


Return to OJS Technical Support

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 5 guests