OJS 3: Add menu items to top navigation bar

How do I add new top level menus and submenus to existing menus? How do I link static pages to the menus? Thanks!

@johnadam241993,

I am having difficulty of finding which files to modify. I looked almost everywhere to find templates or css files to modify the layout etc too but no luck. I shall appreciate it very much if you could point me in the right direction.

Paul

Hi @Paul_Chen,

Is this the reader’s view of the journal, or the editorial back-end?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

It is readers’ view of the journal. Thanks.

Paul

Hi @Paul_Chen,

Try templates/frontend/components/primaryNavMenu.tpl. If changes to that file aren’t reflected when you view the journal, make sure your file permissions in cache/t_compile permit OJS to make changes to its contents.

Regards,
Alec Smecher
Public Knowledge Project Team

@asmecher,

Thanks. I will try that. By the way, where can I find templates for other pages, e.g., home page, article display, etc?

Paul

Hi @Paul_Chen

In OJS 3.0, the reader front-end is entirely implemented in templates/frontend – the structural elements are in pages, and you can see how those bring in additional elements (mostly in objects) by following the includes from there.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Hi @asmecher,

I am looking at headerhead.tpl. There is line “{load_stylesheet context=“frontend” stylesheets=$stylesheets}”. Where is the values for this $stylesheets variable stored? Same questions for loading javascripts. I think I saw it somewhere but again how do I load additional scripts? Should I just place the additional scripts in a designated folder? Thanks.

Hi @Paul_Chen,

Both stylesheets and javascripts are managed using functions in the PKPTemplateManager class. See the addJavaScript and addStyleSheet functions there (both the implementation and several cases of usage).

Regards
Alec Smecher
Public Knowledge Project Team

I would like to add Ahead of print in the main navigation bar. I found the file and created copies of folders and file in the child theme. From my new menu item I need to point to specific issue (number 16) from archives (which serves as an Ahead of print issue).

I use this code:

<a href="{url router=$smarty.const.ROUTE_PAGE page="issue" op="view/16"}">
{translate key="navigation.aheadofprint"}
</a>
</li>
<li>

But this doesent work, as the slash is not transcribed as / in URL, so I end up with:

http//
index.php/jhsci/issue/view%252F16

which gives 404 page.

How to create a proper URL for issue?
How to create an URL for static page?
What file to modify to make a new translation key for new menu items?

Lot of questions from me :flushed:
Best regards,
Dijana

Hi,

You need:
<a href="{url router=$smarty.const.ROUTE_PAGE page="issue" op="view" path="16"}">

URL to a static page
<a href="{url router=$smarty.const.ROUTE_PAGE page="pagepath"}">

Custom translation strings you could handle via a themeplugin. If you want to use the default theme, create a childtheme where you add your own translations and also the custom navigation bar.

2 Likes

Hi @ajnyga,

Works like a charm. Thanks a lot!
Regards,
Dijana

Hi!
I added to templates/frontend/components/primaryNavMenu.tpl the lines

    <li>
    					<a href="{url router=$smarty.const.ROUTE_PAGE page="referee-guidelines"}">
    						{translate key="Referee Guidelines"}
    					</a>
</li>

However now in main navigation menu I have ##Referee Guidelines## displayed.
How can I remove ## ?

Also how can I add the link to the static page to sidebar menu? Is it possible to add to Information block an additional element For Referees, or have I use Custom Block Manager?

Thanks!

1 Like

Hi @novikoffav,

Normally you’d use {translate key="some.symbolic.name}, then add a locale key called some.symbolic.name to the locale file containing the actual translated text.

It’s not best practice, but the simplest thing to do is not to call {translate} at all, just to place Referee Guidelines in the template directly. That’s simpler, but obviously it’ll be fixed in a single language.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

The simple way is to add a new static page by using the static page plugin and edit

  1. “\locale\en_US\local.xml” add something like <'message key=“messages” '>Messages ‘<’/message '>" under ‘<’!-- Navigation -->"
  2. “\templates\frontend\components\primaryNavMenu.tpl” add something like '<‘li>
    <‘a href="{url router=$smarty.const.ROUTE_PAGE page=“messages”}">
    {translate key=“messages”}
    <’/a>
    <’/li> before the last <'ul>
    Note: messages means the path of the page and Messages is the menu item. remove the ’ from html elements if you are doing copy pasting.

For me it is hard to believe that the developers have done such a great job but missed out something crucial as this. Do you think its is possible to develop a MENU PLUGIN for OJS 3?

I managed to create multiple menu items, as

  1. “\locale\en_US\local.xml” add something like this below all codes before closing </locale>. This need to be added one for each menu and in all languages supported by the journal

    Editorial Board
    Associate Editors

“\templates\frontend\components\primaryNavMenu.tpl” add something like before before the last close listing . We need to create one like this for each Menu Items

<li><a href="{url router=$smarty.const.ROUTE_PAGE page="EditorialBoard"}">
{translate key="extra.menu.item1"}
</a>
</li> 
<li><a href="{url router=$smarty.const.ROUTE_PAGE page="AssociateEditors"}">
{translate key="extra.menu.item1"}
</a>
</li> 

The page=“AssociateEditors” the PATH name of the created static page.

I also realised that you can add pages as sub section of ABOUT menu as, but it will display it like http://ojs.dotaca.com/index.php/KJSC/index

<li>
	<a href="{url router=$smarty.const.ROUTE_PAGE page="about" page="EditorialBoard"}">
		{translate key="about.EditorialBoard"}
	</a>
1 Like

This functionality is scheduled for 3.1 (May):

I suggest to integrate this WP open source menu , might be life saving

Greetings,

I wanted to add a menu item / to go to journals home page which helps users from single journal page to go back to multiple journal/index page. i have a problem with the path : i used page = “indexSite” but the link includes the single journal page : index.php/ehkj/indexSite this gives 404 not found , while the required page is : index.php or index.php/indexSite

Back to portal page is your naked domain

If you journal is https://journals.example.com/index.php/j#1

then your portal will be https://journals.example.com