Describe the issue or problem
Some of our journals are displaying the full text of their articles in HTML on their landing page, and we have added a table of contents that is displayed under the galleys on the side. To generate the HTML, we use the JATSParser plugin. To display the table of contents, we created a child theme for the default theme and added a JavaScript file as well as modified article_details.tpl.
In the process of upgrading from version 3.3 to version 3.5, we realized in testing that if we display the table of contents, the How To Cite block from the Citation Style Language plugin would disappear.
Is there a reason why it would disappear? Is there a way to display both the custom table of contents and the How To Cite block like we could in OJS 3.3?
Steps I took leading up to the issue
- Enable Citation Style Language plugin
- How to Cite block displays on the article landing page
- Enable JATSParser plugin and custom default child theme plugin
- Table of contents displays, but the how to cite block does not
What application are you using?
OJS 3.5.0-1
Additional information
Exemple in OJS 3.3 : Sedimentologika
Exemple in OJS 3.5 : Sedimentologika
Custom child theme (parent : Default)
\templates\frontend\objects\article_details.tpl
line 317 - added the following code
{* Dynamic Table of content *}
<div class="jatsParser__intraarticle-menu">
<div id="jatsParser__navbar-article" class="jatsParser__navbar">
<nav class="jatsParser__navbar-items" id="jatsParser__navbarItems">
{* adding menu by javascript here *}
</nav>
</div>
</div><!-- End JATS ajout MC 24-08-2022 -->
\js\main.js
// Navigation inside an article
(function () {
var navbar = document.getElementById("jatsParser__navbarItems");
var sectionTitles = document.getElementsByClassName("article-section-title");
var hasSubtitles = 0;
var intranav;
if (sectionTitles.length < 2) {
var elTodelete = document.querySelector(".jatsParser__intraarticle-menu");
elTodelete.parentNode.removeChild(elTodelete);
return;
}
for (var i = 0; i < sectionTitles.length; i++) {
var sectionTitle = sectionTitles.item(i);
if (sectionTitle.tagName === "H2") {
sectionTitle.setAttribute("id", "title-" + i);
var newNavItem = document.createElement("A");
newNavItem.setAttribute("class", "jatsParser__nav-link");
newNavItem.setAttribute("href", "#title-" + i);
var newNavItemText = document.createTextNode(sectionTitle.textContent);
newNavItem.appendChild(newNavItemText);
navbar.appendChild(newNavItem);
hasSubtitles = 0;
} else if (sectionTitle.tagName === "H3") {
hasSubtitles++;
sectionTitle.setAttribute("id", "title-" + i);
if (hasSubtitles === 1) {
intranav = document.createElement("NAV");
intranav.setAttribute("class", "jatsParser__subnavbar-items");
navbar.appendChild(intranav);
}
var newSubNavItem = document.createElement("A");
newSubNavItem.setAttribute("class", "jatsParser__subnav-link");
newSubNavItem.setAttribute("href", "#title-" + i);
var newSubNavItemText = document.createTextNode(sectionTitle.textContent);
newSubNavItem.appendChild(newSubNavItemText);
intranav.appendChild(newSubNavItem);
}
}
})();
// ScrollSpy
(function () {
function trackElement(headLvl, navLvl) {
// Sections position
var sectionTitles = document.getElementsByClassName("article-section-title");
var arrayReturn = sectionTitlePos(sectionTitles, headLvl);
var closestToZeroElement = arrayReturn[0];
var minimum = arrayReturn[1];
var navItems = document.getElementsByClassName(navLvl);
if (closestToZeroElement != null) {
var closestToZeroElementId = closestToZeroElement.getAttribute("id");
for (var y = 0; y < navItems.length; y++) {
var navItem = navItems.item(y);
var linkTo = navItem.getAttribute("href").trim().substr(1);
if (linkTo === closestToZeroElementId) {
// Remove highlight from the last subheading if next heading is reached
if (headLvl === "H3" && !isParentActive(navItem)) {
if (navItem.classList.contains("active")) {
navItem.classList.remove("active");
}
}
if (navItem.classList.contains("active")) {
return;
}
}
if (navItem.classList.contains("active")) {
navItem.classList.remove("active");
}
// Add highlight except to subheadings from different sections
if (linkTo === closestToZeroElementId) {
if (headLvl !== "H3" || isParentActive(navItem)) {
navItem.classList.add("active");
}
}
}
} else if (minimum === 1) {
for (var z = 0; z < navItems.length; z++) {
if (navItems.item(z).classList.contains("active")) {
navItems.item(z).classList.remove("active");
}
}
}
}
/* do not trigger scroll listening too often */
var ticking = false;
window.addEventListener("scroll", function(e) {
if (!ticking) {
window.setTimeout(function() {
trackElement("H2", "jatsParser__nav-link");
trackElement("H3", "jatsParser__subnav-link");
ticking = false;
}, 500);
ticking = true;
}
});
function sectionTitlePos(sectionTitles, headingLevel) {
var closestToZeroElement = null;
var minimum = 1;
for (var i = 0; i < sectionTitles.length; i++) {
var sectionTitle = sectionTitles.item(i);
if (sectionTitle.tagName === headingLevel) {
var rect = sectionTitle.getBoundingClientRect();
if (rect.top >= 1) {
continue;
}
if (minimum === 1 || rect.top > minimum) {
closestToZeroElement = sectionTitle;
minimum = rect.top;
}
}
}
return [closestToZeroElement, minimum];
}
function isParentActive(navItem) {
return navItem.parentElement.previousElementSibling.classList.contains("active");
}
})();
// Modal for figures
(function () {
var els = document.querySelectorAll("figure, table");
for (var i = 0; i < els.length; i++) {
var expandEl = document.createElement("button");
expandEl.setAttribute("class", "jatsParser__expand");
expandEl.textContent = "\u2197";
els.item(i).insertBefore(expandEl, els.item(i).firstChild);
}
})();
(function () {
var clicked = false;
var figures = document.querySelectorAll("#jatsParserFullText figure, #jatsParserFullText table");
var documentBody = document.body;
var documentFadeClass = "jatsParser__fade";
var pageYoffset = 0;
for (var i = 0; i < figures.length; i++) {
var expandEl = figures.item(i).querySelector(".jatsParser__expand");
expandEl.addEventListener("click", function () {
if (clicked) {
return false;
}
clicked = true;
pageYoffset = window.pageYOffset;
var modalContent = null;
var parentEl = this.parentElement;
if (parentEl.tagName === "figure") {
modalContent = parentEl.cloneNode(true);
modalContent.setAttribute("id", "modal-" + modalContent.getAttribute("id"));
} else {
modalContent = document.createElement("div");
var clonedContent = parentEl.cloneNode(true);
modalContent.appendChild(clonedContent);
modalContent.setAttribute("id", "modal-" + clonedContent.getAttribute("id"));
}
modalContent.classList.add("jatsParser__modal");
documentBody.classList.add("jatsParser__fade");
documentBody.insertBefore(modalContent, documentBody.firstChild);
var elToRemove = modalContent.querySelector(".jatsParser__expand");
elToRemove.parentElement.removeChild(elToRemove);
window.scrollTo(0, 0);
var closeEl = document.createElement("button");
closeEl.setAttribute("id", "jatsParser__close");
closeEl.setAttribute("aria-label", "close");
closeEl.textContent = "\u2199";
modalContent.insertBefore(closeEl, modalContent.firstChild);
closeEl.addEventListener("click", function () {
documentBody.removeChild(modalContent);
documentBody.classList.remove(documentFadeClass);
window.scrollTo(0, pageYoffset);
clicked = false;
});
});
}
})();