I am attempting to add a new menu item to the primary nav. The new nav looks something like this:
It basically just shows the latest issue along with the four most recent articles from any issues. The modifications I have made to the primaryNavMenu.tpl will only render the new menu item IF $issue is set. The menu displays correctly for most pages, however for some it does not display at all because $issue is not set, and for others it will display the wrong issue because the current issue value is not the same as the most recent issue for some reason.
If I am viewing any issue that is NOT the current issue, then the $issue value differs and will be set to match the issue being viewed, i.e. the menu entry should be showing Vol 1 Issue 2 because that is the current issue but viewing Vol 1 Issue 1, the older issue, will show that issue in the menu as being the current one:
My question is: How can I reliably get the current issue value and make that value available to all pages on the frontend, not just some of the pages?
This is still a problem for me - the code that retrieves the current issue only retrieves the issue being viewed and not the most recent chronological issue.
The getCurrent method in the IssueDAO returns which ever issue has the current attribute set to 1 in the database. It is not necessarily chronological because that value can be changed using the “set current” link below any issue in the issues area. You may be experiencing weird caching behaviour because you are passing in true as your second argument which tells OJS to use the cache, not to fetch from the database:
and
If you want the most recent issue in chronological order you’ll probably need a plugin or a theme modification that fetches issues and sorts by date published, and then limit the query to a single record.
Most helpful. I managed to get it working by getting a list of all issues and taking the first one - this appears to be consistent irrespective of which issue is being viewed currently.
There might be a bit of confusion here. getCurrent does not return the issue you are currently viewing. It returns the issue that is marked as the “current” one (that is, the one that appears on the journal index in the table of contents). It will always be that one. It is set via the “set current” below the issue in the Issue grid in the journal settings area.