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

Many times we as the journal staff only want to display a brief announcement (the “Short Description” only) on the home page, with no need for the “Read More” link to the full “Announcement” text.

I understand I can edit the CSS style sheet to change the Read More button to “display: none;” (per info from @Michevole at How to delete "Read more" in the display of the announcement on the journal homepage) . But then we won’t have a choice (without editing the style sheet back to the default) of displaying longer announcements, where we do want to have the Read More link and the full Announcement text.

What would make more sense is that IF the Announcement field is blank, THEN the Read More link doesn’t appear.

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

Hi @achristian, we are trying to make all first “Feature Request” posts follow the same structure to facilitate the understanding of the petitions and, at same time, ensure no relevant info is missing.

Do you mind to reEdit your fist post following this template:

Describe the problem you would like to solve
Example: Our editors need a way to […]

Describe the solution you’d like
Tell us how you would like this problem to be solved.

Who is asking for this feature?
Tell us what kind of users are requesting this feature. Example: Journal Editors, Journal Administrators, Technical Support, Authors, Reviewers, etc.

Additional information
Add any other information or screenshots about the feature request here.

You can use this post as a reference.

Please don’t answer this post: As soon as you make the changes, we will remove this post to avoid adding noise to your FR thread.

Thanks for your help.