Get current journal ID [Open Journal Systems]

Is there a function that return the current journal ID in my OJS version?, considering that journal path is in the URL, so exploding the URL and querying the database we can get journal ID

thanks a lot!!!


Hi @marcello8080,

That should be as simple as $journal->getId() – though way back in OJS 2.3.1-2 it might’ve been $journal->getJournalId(). If that’s not helpful, can you provide a bit more information about where you’re trying to add this?

Alec Smecher
Public Knowledge Project Team

Thanks a lot Asmecher

I think there is a core variable in order to display the current journal ID which is $currentJournalId

So if I have to display the subscriptions regarding the current journal ID I will do:

{foreach from=$journalSubscriptions item=subscription}
     {if $currentJournalId == $subscription.journal_id}

I wonder how I can get the journal ID on a class if the $journal class is not initialised, if I display
$journal = new Journal();
echo $journal->getJournalId();
it will display NULL

Hi @marcello8080,

Are you trying to put that code into a Smarty template, or a PHP class? If PHP, then where?

Alec Smecher
Public Knowledge Project Team

The code that I provided is going to a smarty template and it is working.

the pure php code is going to a class called but it doesn’t generate any result, I think I need to initialise the $journal class first.

In any case I reach what I wanted to do