How to make italics in article title in OJS 3

Hi there,

I’ve done the following to make italics work in article titles, but exclude them from metadata (DC.Title and citation_title) and the browser’s title bar.

You need to change some templates - there might be a better way to do it, but it works for me.

Replace “escape” by “strip_unsafe_html” in /ojs/templates/frontend/objects/article_details.tpl in the “title” and “subtitle” to make italics work on the article’s frontdoor

<h1 class="page_title">
  {$article->getLocalizedTitle()|strip_unsafe_html}
</h1>

{if $article->getLocalizedSubtitle()}
  <h2 class="subtitle">
    {$article->getLocalizedSubtitle()|strip_unsafe_html}
  </h2>
{/if}

Replace “escape” by “strip_unsafe_html” in /ojs/templates/frontend/pages/article.tpl to strip html tags in the browser’s title bar

{include file="frontend/components/header.tpl" pageTitleTranslated=$article->getLocalizedTitle()|strip_unsafe_html}

Add “strip_unsafe_html” in /ojs/plugins/generic/dublinCoreMeta/DublinCoreMetaPlugin.inc in “DC.Title” to strip html tags in DC.Title

$templateMgr->addHeader('dublinCoreTitle', '<meta name="DC.Title" content="' . htmlspecialchars(strip_tags($article->getTitle($article->getLocale()))) . '"/>');

Do the same in /ojs/plugins/generic/googleScholar/GoogleScholarPlugin.inc.php in “googleScholarTitle”

$templateMgr->addHeader('googleScholarTitle', '<meta name="citation_title" content="' . htmlspecialchars(strip_tags($article->getTitle($article->getLocale()))) . '"/>');

Et voila - you will have italics an your article’s frontdoor, but no “em” or “i” html tags in the browser’s titlebar or in the DC.Title / citation_title metadata

6 Likes