Review form items in OJS

We are having a issue with review forms in OJS 2.4.5. As shown in the attached file, some form items do not display their actual text on the overview screen, replaced instead by ellipses (…). This occurs mainly with form items that include radio buttons rather than text boxes, but the behavior is not consistent (the REQUIRED form item, for example, is a radio button). I have checked the HTML in the form items and haven’t discovered any likely possibilities there either. Any ideas?

Hi @iupj,

It looks like something is going wrong with the code that truncates entries that it thinks are too long for the listing. That’s used comprehensively throughout OJS so I’m not sure what’s happening there, but you can fix it by editing templates/manager/reviewForms/reviewFormElements.tpl and finding the line…

<td class="drag">{$reviewFormElement->getLocalizedQuestion()|truncate:200:"..."}</td>

Change it to…

<td class="drag">{$reviewFormElement->getLocalizedQuestion()}</td>

Regards,
Alec Smecher
Public Knowledge Project Team

We unfortunately do not have direct access to the template files. I have not been able to figure out what exactly causes the problem, but I think it has something to do with HTML tags in the review form. If I prune some of them out of the form item it does truncate correctly.

Hi @iupj,

If you start the question out with a long HTML tag, then yes, that’s likely what’s causing it. OJS tries to truncate the question down below 200 characters for display in listings, but IIRC that 200 character limit includes HTML tags.

Regards,
Alec Smecher
Public Knowledge Project Team

Should this be submitted as a bug? We aren’t inserting any complicated HTML, just the tags that are automatically applied via the TinyMCE interface.

Hi @iupj,

Yes, I’ll take a look.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @iupj,

I was hoping to find a simple third-party library that we could use to replace our truncation code, which is behaving problematically in your case, but unfortunately not much exists. The closest I could find is this:

http://www.pjgalbraith.com/truncating-text-html-with-php/

Part of the problem is that solving this on the server-side is inherently a bad solution. It should be solved on the front end, via CSS and HTML, permitting the theme to decide what limits are appropriate based on layout rules rather than a fixed number of characters for certain types of data.

A better solution using CSS will hopefully be included in OJS 3.0, but in the meantime I think a solution for OJS 2.x will require a lot of work. In the meantime I’d suggest making the modification I suggested above.

I’ve filed the 3.0 solution in our bug tracker: Delegate truncation to CSS · Issue #446 · pkp/pkp-lib · GitHub

Regards,
Alec Smecher
Public Knowledge Project Team

Thank you so much for looking into this; we’ll try to implement the fix you recommended and eagerly await OJS 3.0!