Turn off “Read more” in the display of the announcement on the journal homepage

Hi @achristian!

PHP is not my first language (:grinning_face_with_smiling_eyes:), but I improved my editing ability since my last post in that thread.

If you use the OJS 3 Default Theme, you have to edit just a single file to obtain the smart behavior of “Read more” button. You need the access to the ojs files in your server. Open the following file:
…/lib/pkp/templates/frontend/objects/announcement_summary.tpl

Search these lines:

<div class="summary">
		{$announcement->getLocalizedDescriptionShort()|strip_unsafe_html}
		<a href="{url router=PKPApplication::ROUTE_PAGE page="announcement" op="view" path=$announcement->getId()}" class="read_more">
			<span aria-hidden="true" role="presentation">
				{translate key="common.readMore"}
			</span>
			<span class="pkp_screen_reader">
				{translate key="common.readMoreWithTitle" title=$announcement->getLocalizedTitle()|escape}
			</span>
		</a>
	</div>

and replace them with the following ones:

	<div class="summary">
		{$announcement->getLocalizedDescriptionShort()|strip_unsafe_html}
		{if $announcement->getLocalizedDescription()}
		<a href="{url router=$smarty.const.ROUTE_PAGE page="announcement" op="view" path=$announcement->getId()}" class="read_more">
			<span aria-hidden="true" role="presentation">
				{translate key="common.readMore"}
			</span>
			<span class="pkp_screen_reader">
				{translate key="common.readMoreWithTitle" title=$announcement->getLocalizedTitle()|escape}
			</span>
		</a>
		{else}{/if}
	</div>

With these changes, the “Read more” button will be displayed only when a long description is present. It works with the Default Theme.

Actually I just put a condition in the template in the form: “if there’s a long description, put the button, if not do nothing”.

I hope it works for you, bye

1 Like