To load script only on index context

Hello.

OJS 3.2.1

I used this code:

$this->addScript(
      'rss',
      '/public/site/rss.js',
      array('baseUrl' => '')
 );

JS script loads in frontend, but i would like that only it will load at indexJournal.

Context is frontend or backend, frontend by default, but, can i use context => index or something?

Thanks

Hi @juanito,

As far as I remember, you can use something like:

$requestedPage = $this->getRequest()->getRequestedPage();
if ($requestedPage === 'index' || $requestedPage === '') {
...
} 
1 Like

Thank you very much @Vitaliy .

It works!