OJS Adding toc home page

In OJS I’m trying to get the table of contents for current issue on the home journal.tpl. I have found the template that has the code in it for the table the issue.tpl but can’t seem to get the table to show up without remove an image from the article.

Hi @FlaminSeraphim,

It sounds like you have a cover image for the issue, but don’t want it shown. Why not just remove it if that’s the case?

Regards,
Alec Smecher
Public Knowledge Project Team

@asmecher I have a cover image and I do want it to show as well as the table of contents next to it. But there is code that whenever there is a cover image it doesn’t show the table of contents.

Hi @FlaminSeraphim,

What version of OJS are you using?

Regards,
Alec Smecher
Public Knowledge Project Team

@asmecher 2.4.8 is the ojs version we are using.

Hi @FlaminSeraphim,

Off the top of my head, you may need to modify the call to IssueHandler::_setupIssueTemplate in pages/index/IndexHandler.inc.php. That function has an optional 3rd parameter called $showToc that, when set to true, should present the table of contents rather than the cover image. I haven’t tested whether this will have unintended side-effects, but should get you at least most of the way there.

Regards,
Alec Smecher
Public Knowledge Project Team

@asmecher I see a couple areas that talk about that variable in the file but whenever I tried to force them to be true it would either break the site or just auto hide the image.

Hi @FlaminSeraphim,

Can you describe exactly what you changed and the effect it had? I can’t necessarily guide you through this modification in detail but I might be able to spot a problem.

Regards,
Alec Smecher
Public Knowledge Project Team

Here is the code to the function that is controlling the TOC. I changed for value of $showToc to true and it hides the picture but displays the table of content.s

function _setupIssueTemplate($request, $issue, $showToc = (here I changed this to true) false) {
$journal =& $request->getJournal();
$journalId = $journal->getId();
$templateMgr =& TemplateManager::getManager();
if (IssueHandler::_isVisibleIssue($issue, $journalId)) {

		$issueHeadingTitle = $issue->getIssueIdentification(false, true);
		$issueCrumbTitle = $issue->getIssueIdentification(false, true);

		$locale = AppLocale::getLocale();

		import('classes.file.PublicFileManager');
		$publicFileManager = new PublicFileManager();
		$coverPagePath = $request->getBaseUrl() . '/';
		$coverPagePath .= $publicFileManager->getJournalFilesPath($journalId) . '/';
		$templateMgr->assign('coverPagePath', $coverPagePath);
		$templateMgr->assign('locale', $locale);

		$coverLocale = $issue->getFileName($locale) ? $locale : $journal->getPrimaryLocale();
		if (!$showToc && $issue->getFileName($coverLocale) && $issue->getShowCoverPage($coverLocale) && !$issue->getHideCoverPageCover($coverLocale)) {
			$templateMgr->assign('fileName', $issue->getFileName($coverLocale));
			$templateMgr->assign('width', $issue->getWidth($coverLocale));
			$templateMgr->assign('height', $issue->getHeight($coverLocale));
			$templateMgr->assign('coverPageAltText', $issue->getCoverPageAltText($coverLocale));
			$templateMgr->assign('originalFileName', $issue->getOriginalFileName($coverLocale));
			$templateMgr->assign('coverLocale', $coverLocale);

			// default value false
			$showToc = false;

		} else {

			// Issue galleys
			$issueGalleyDao =& DAORegistry::getDAO('IssueGalleyDAO');
			$issueGalleys =& $issueGalleyDao->getGalleysByIssue($issue->getId());
			$templateMgr->assign_by_ref('issueGalleys', $issueGalleys);

			// Published articles
			$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
			$publishedArticles =& $publishedArticleDao->getPublishedArticlesInSections($issue->getId(), true);

			$publicFileManager = new PublicFileManager();
			$templateMgr->assign_by_ref('publishedArticles', $publishedArticles);
			$showToc = true;
		}
		$templateMgr->assign('showToc', $showToc);
		$templateMgr->assign_by_ref('issue', $issue);

		// Subscription Access
		import('classes.issue.IssueAction');
		$subscriptionRequired = IssueAction::subscriptionRequired($issue);
		$subscribedUser = IssueAction::subscribedUser($journal);
		$subscribedDomain = IssueAction::subscribedDomain($journal);
		$subscriptionExpiryPartial = $journal->getSetting('subscriptionExpiryPartial');

		if ($showToc && $subscriptionRequired && !$subscribedUser && !$subscribedDomain && $subscriptionExpiryPartial) {
			$templateMgr->assign('subscriptionExpiryPartial', true);

			// Partial subscription expiry for issue
			$partial = IssueAction::subscribedUser($journal, $issue->getId());
			if (!$partial) IssueAction::subscribedDomain($journal, $issue->getId());
			$templateMgr->assign('issueExpiryPartial', $partial);

			// Partial subscription expiry for articles
			$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
			$publishedArticlesTemp =& $publishedArticleDao->getPublishedArticles($issue->getId());

			$articleExpiryPartial = array();
			foreach ($publishedArticlesTemp as $publishedArticle) {
				$partial = IssueAction::subscribedUser($journal, $issue->getId(), $publishedArticle->getId());
				if (!$partial) IssueAction::subscribedDomain($journal, $issue->getId(), $publishedArticle->getId());
				$articleExpiryPartial[$publishedArticle->getId()] = $partial;
			}
			$templateMgr->assign_by_ref('articleExpiryPartial', $articleExpiryPartial);
		}

		$templateMgr->assign('subscriptionRequired', $subscriptionRequired);
		$templateMgr->assign('subscribedUser', $subscribedUser);
		$templateMgr->assign('subscribedDomain', $subscribedDomain);
		$templateMgr->assign('showGalleyLinks', $journal->getSetting('showGalleyLinks'));

		import('classes.payment.ojs.OJSPaymentManager');
		$paymentManager = new OJSPaymentManager($request);
		if ( $paymentManager->onlyPdfEnabled() ) {
			$templateMgr->assign('restrictOnlyPdf', true);
		}
		if ( $paymentManager->purchaseArticleEnabled() ) {
			$templateMgr->assign('purchaseArticleEnabled', true);
		}

	} else {
		$issueCrumbTitle = __('archive.issueUnavailable');
		$issueHeadingTitle = __('archive.issueUnavailable');
	}

	if ($issue && $styleFileName = $issue->getStyleFileName()) {
		import('classes.file.PublicFileManager');
		$publicFileManager = new PublicFileManager();
		$templateMgr->addStyleSheet(
			$request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journalId) . '/' . $styleFileName
		);
	}

	$templateMgr->assign('pageCrumbTitleTranslated', $issueCrumbTitle);
	$templateMgr->assign('issueHeadingTitle', $issueHeadingTitle);
}

Hi @FlaminSeraphim,

That’s a little hard to read – you can format code here using Markdown – but in any case, I don’t think that’s necessary. You should be able to just find the call to _setupIssueTemplate in IndexHandler and add the 3rd parameter (true) to override the default value of false.

Regards,
Alec Smecher
Public KnowledgeProject Team

– function _setupIssueTemplate($request, $issue, $showToc = true) { //forced true value here is this not where you were indicating for me to change to true?
$journal =& $request->getJournal();
$journalId = $journal->getId();
$templateMgr =& TemplateManager::getManager();
if (IssueHandler::_isVisibleIssue($issue, $journalId)) {

		$issueHeadingTitle = $issue->getIssueIdentification(false, true);
		$issueCrumbTitle = $issue->getIssueIdentification(false, true);

		$locale = AppLocale::getLocale();

		import('classes.file.PublicFileManager');
		$publicFileManager = new PublicFileManager();
		$coverPagePath = $request->getBaseUrl() . '/';
		$coverPagePath .= $publicFileManager->getJournalFilesPath($journalId) . '/';
		$templateMgr->assign('coverPagePath', $coverPagePath);
		$templateMgr->assign('locale', $locale);

		$coverLocale = $issue->getFileName($locale) ? $locale : $journal->getPrimaryLocale();
		if (!$showToc && $issue->getFileName($coverLocale) && $issue->getShowCoverPage($coverLocale) && !$issue->getHideCoverPageCover($coverLocale)) {
			$templateMgr->assign('fileName', $issue->getFileName($coverLocale));
			$templateMgr->assign('width', $issue->getWidth($coverLocale));
			$templateMgr->assign('height', $issue->getHeight($coverLocale));
			$templateMgr->assign('coverPageAltText', $issue->getCoverPageAltText($coverLocale));
			$templateMgr->assign('originalFileName', $issue->getOriginalFileName($coverLocale));
			$templateMgr->assign('coverLocale', $coverLocale);

			// default value false
			$showToc = false;

		} else {

			// Issue galleys
			$issueGalleyDao =& DAORegistry::getDAO('IssueGalleyDAO');
			$issueGalleys =& $issueGalleyDao->getGalleysByIssue($issue->getId());
			$templateMgr->assign_by_ref('issueGalleys', $issueGalleys);

			// Published articles
			$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
			$publishedArticles =& $publishedArticleDao->getPublishedArticlesInSections($issue->getId(), true);

			$publicFileManager = new PublicFileManager();
			$templateMgr->assign_by_ref('publishedArticles', $publishedArticles);
			$showToc = true;
		}
		$templateMgr->assign('showToc', $showToc);
		$templateMgr->assign_by_ref('issue', $issue);

		// Subscription Access
		import('classes.issue.IssueAction');
		$subscriptionRequired = IssueAction::subscriptionRequired($issue);
		$subscribedUser = IssueAction::subscribedUser($journal);
		$subscribedDomain = IssueAction::subscribedDomain($journal);
		$subscriptionExpiryPartial = $journal->getSetting('subscriptionExpiryPartial');

		if ($showToc && $subscriptionRequired && !$subscribedUser && !$subscribedDomain && $subscriptionExpiryPartial) {
			$templateMgr->assign('subscriptionExpiryPartial', true);

			// Partial subscription expiry for issue
			$partial = IssueAction::subscribedUser($journal, $issue->getId());
			if (!$partial) IssueAction::subscribedDomain($journal, $issue->getId());
			$templateMgr->assign('issueExpiryPartial', $partial);

			// Partial subscription expiry for articles
			$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
			$publishedArticlesTemp =& $publishedArticleDao->getPublishedArticles($issue->getId());

			$articleExpiryPartial = array();
			foreach ($publishedArticlesTemp as $publishedArticle) {
				$partial = IssueAction::subscribedUser($journal, $issue->getId(), $publishedArticle->getId());
				if (!$partial) IssueAction::subscribedDomain($journal, $issue->getId(), $publishedArticle->getId());
				$articleExpiryPartial[$publishedArticle->getId()] = $partial;
			}
			$templateMgr->assign_by_ref('articleExpiryPartial', $articleExpiryPartial);
		}

		$templateMgr->assign('subscriptionRequired', $subscriptionRequired);
		$templateMgr->assign('subscribedUser', $subscribedUser);
		$templateMgr->assign('subscribedDomain', $subscribedDomain);
		$templateMgr->assign('showGalleyLinks', $journal->getSetting('showGalleyLinks'));

		import('classes.payment.ojs.OJSPaymentManager');
		$paymentManager = new OJSPaymentManager($request);
		if ( $paymentManager->onlyPdfEnabled() ) {
			$templateMgr->assign('restrictOnlyPdf', true);
		}
		if ( $paymentManager->purchaseArticleEnabled() ) {
			$templateMgr->assign('purchaseArticleEnabled', true);
		}

	} else {
		$issueCrumbTitle = __('archive.issueUnavailable');
		$issueHeadingTitle = __('archive.issueUnavailable');
	}

	if ($issue && $styleFileName = $issue->getStyleFileName()) {
		import('classes.file.PublicFileManager');
		$publicFileManager = new PublicFileManager();
		$templateMgr->addStyleSheet(
			$request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journalId) . '/' . $styleFileName
		);
	}

	$templateMgr->assign('pageCrumbTitleTranslated', $issueCrumbTitle);
	$templateMgr->assign('issueHeadingTitle', $issueHeadingTitle);
} --

Hi @FlaminSeraphim,

In pages/index/IndexHandler.inc.php, change…

 IssueHandler::_setupIssueTemplate($request, $issue);

…to…

IssueHandler::_setupIssueTemplate($request, $issue, true);

You may need to do some more digging if that doesn’t work as expected.

Regards,
Alec Smecher
Public Knowledge Project Team

@asmecher when I set it to true it just show the table of contents. No cover page for the current issue.

Hi @FlaminSeraphim,

Sorry, I thought that was what you were asking for. What are you looking to do?

Regards,
Alec Smecher
Public Knowledge Project Team

@asmecher I want to be able to have both the table of contents and the cover image side by side on the journal index page.

Hi @FlaminSeraphim,

OK, you’ll have to work with both the templates and the PHP to accomplish that. Currently it’s an either/or proposition. Unfortunately I can’t guide you through this in detail, though you’ve already identified the right areas to work with – but if you’re stuck on something specific, I may be able to review your work in progress. The best way to do that is to post it on github so I can easily compare the original code with your modified version.

Regards,
Alec Smecher
Public Knowledge Project Team

@asmecher
I was able to get the cover image to show by commenting out code on line 443.

`function _setupIssueTemplate($request, $issue, $showToc = true) {
$journal =& $request->getJournal();
$journalId = $journal->getId();
$templateMgr =& TemplateManager::getManager();
if (IssueHandler::_isVisibleIssue($issue, $journalId)) {

		$issueHeadingTitle = $issue->getIssueIdentification(false, true);
		$issueCrumbTitle = $issue->getIssueIdentification(false, true);

		$locale = AppLocale::getLocale();

		import('classes.file.PublicFileManager');
		$publicFileManager = new PublicFileManager();
		$coverPagePath = $request->getBaseUrl() . '/';
		$coverPagePath .= $publicFileManager->getJournalFilesPath($journalId) . '/';
		$templateMgr->assign('coverPagePath', $coverPagePath);
		$templateMgr->assign('locale', $locale);

		$coverLocale = $issue->getFileName($locale) ? $locale : $journal->getPrimaryLocale();
		// if (!$showToc && $issue->getFileName($coverLocale) && $issue->getShowCoverPage($coverLocale) && !$issue->getHideCoverPageCover($coverLocale)) {
		// 	$templateMgr->assign('fileName', $issue->getFileName($coverLocale));
		// 	$templateMgr->assign('width', $issue->getWidth($coverLocale));
		// 	$templateMgr->assign('height', $issue->getHeight($coverLocale));
		// 	$templateMgr->assign('coverPageAltText', $issue->getCoverPageAltText($coverLocale));
		// 	$templateMgr->assign('originalFileName', $issue->getOriginalFileName($coverLocale));
			$templateMgr->assign('coverLocale', $coverLocale);
		//
		// 	// default value false
		// 	$showToc = false;
		//
		// } else {

			// Issue galleys
			$issueGalleyDao =& DAORegistry::getDAO('IssueGalleyDAO');
			$issueGalleys =& $issueGalleyDao->getGalleysByIssue($issue->getId());
			$templateMgr->assign_by_ref('issueGalleys', $issueGalleys);'

`

After that I moved some stuff in the view.tpl template. There is a line of code

<div id="issueCoverImage"><a href="{$currentUrl}"><img src="{$coverPagePath|escape}{$issue->getFileName($coverLocale)|escape}"{if $coverPageAltText != ''} alt="{$coverPageAltText|escape}"{else} alt="{translate key="issue.coverPage.altText"}"{/if}{if $width} width="{$width|escape}"{/if}{if $height} height="{$height|escape}"{/if}/></a></div>

I moved it to below

{if !$showToc && $issue} {if $issueId} {url|assign:"currentUrl" page="issue" op="view" path=$issueId|to_array:"showToc"} {else} {url|assign:"currentUrl" page="issue" op="current" path="showToc"} {/if} <ul class="menu"> <li><a href="{$currentUrl}">{translate key="issue.toc"}</a></li> </ul> <br /> <div id="issueCoverImage"><a href="{$currentUrl}"><img src="{$coverPagePath|escape}{$issue->getFileName($coverLocale)|escape}"{if $coverPageAltText != ''} alt="{$coverPageAltText|escape}"{else} alt="{translate key="issue.coverPage.altText"}"{/if}{if $width} width="{$width|escape}"{/if}{if $height} height="{$height|escape}"{/if}/></a></div> <div id="issueCoverDescription">{$issue->getLocalizedCoverPageDescription()|strip_unsafe_html|nl2br}</div> {elseif $issue}

Hi @FlaminSeraphim,

Glad to hear you got it going!

Regards,
Alec Smecher
Public Knowledge Project Team

It works! thanks alot. this by far is the simplest most effective fix for the problem