3.x get a journal id or name in current article

Hi

I’m trying to get the journal id for a current article within article_details.tpl.

I need to only embed some code on a particular journal. If implementing in pure php I would be thinking something like:

if ($article->getJournal()->getName() == 'my_journal') then
   // show code snippet
endif;

How is this achievable in a smart template using the OJS API?

Thanks

Did you try $journal -> getPath() ?

Overall, if you have a multijournal installation of OJS and plan to do something special in a template that should only apply to a single journal, I would recommend using a child theme for that journal and adding a modified template file the the child theme plugin.

In Smarty syntax, that would be e.g.:

{if $journal->getPath() == 'abcd'}
    <strong>This is journal ABCD.</strong>
{/if}

Regards,
Alec Smecher
Public Knowledge Project Team

Great thanks.

I implemented the suggested code:

{if $journal->getPath() == "sajs"}
    <!-- Start Crossmark Snippet v2.0 -->

    <script src="https://crossmark-cdn.crossref.org/widget/v2.0/widget.js"></script>
    <div style="padding-top: 20px; text-align: right;">
        <a data-target="crossmark"><img src="https://crossmark-cdn.crossref.org/widget/v2.0/logos/CROSSMARK_Color_horizontal.svg" style="width: 150px;"/></a>
    </div>
    <!-- End Crossmark Snippet -->
{/if}

But it seems to just terminate without processing the rest of the template. No errors in the logs either.

Hi @haydenyoung,

I’m surprised that nothing is getting logged. Something else to double-check – are the file permissions in cache/t_compile set correctly? OJS needs to be able to replace the files there when a template gets modified.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher

Details of permissions:

drwxr-xr-x 2 www-data www-data 147456 Aug 23 09:32 /var/www/html/cache/t_compile/

I’m wondering; does the $journal var need to be instantiated or should it be available in the article_details.tpl? Only other thing I can think of off the top of my head although I would have thought referencing the non-instantiated $journal object would have thrown an error (unless maybe smarty catches these errors).

Hi @haydenyoung,

Ah, try using $currentJournal instead of $journal. (This should be showing up in the error log as a fatal error, I think – but anyway.)

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher

great thanks again, worked!

{if $currentJournal->getPath() == 'sajs'}
...
{/if} 

@haydenyoung