bug PR-5.2-dev Pending

User tests: Successful: Unsuccessful:

avatar conseilgouz
conseilgouz
1 Oct 2024

In articles module, if introtext limit is set to a non zero value, all html tags (ul, li, hx,...) are removed.

Summary of Changes

In mod_articles/src/Helper/ArticlesHelper.php, line 371, replacing truncate by truncateComplex preserves as much HTML code as possible.

Note : in current version, line 371 contains a bug, it performs a truncate with introtext when it should be displayIntrotext

Testing Instructions

Create one article with some html like text formatting, ul, li, .... in its first 100 characters.
Create an Articles module so that it will display your article and set introtext limit to 100.

Actual result BEFORE applying this Pull Request

In articles modules, articles are displayed as plain text.

Expected result AFTER applying this Pull Request

In articles modules, articles are displayed with as much HTML as possible.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar conseilgouz conseilgouz - change - 1 Oct 2024
Status New Pending
avatar conseilgouz conseilgouz - open - 1 Oct 2024
avatar joomla-cms-bot joomla-cms-bot - change - 1 Oct 2024
Category Modules Front End
avatar conseilgouz conseilgouz - change - 1 Oct 2024
The description was changed
avatar conseilgouz conseilgouz - edited - 1 Oct 2024
avatar conseilgouz conseilgouz - change - 1 Oct 2024
Title
[5.2] Articles module : setting Introtext Limit destroy article html formats
[5.2] Articles module : setting Introtext Limit destroys article html formats
avatar conseilgouz conseilgouz - edited - 1 Oct 2024
avatar drmenzelit
drmenzelit - comment - 2 Oct 2024

The "..." on a new line are annoying

avatar Kostelano
Kostelano - comment - 2 Oct 2024

It works, I can send a successful test. But I agree with the previous comment, the ellipsis on the new line looks not very appropriate.

avatar Fedik
Fedik - comment - 2 Oct 2024

I think it was overlooked in original PR, but the code should use HTMLHelper::_();

HTMLHelper::_('string.truncate', $text, $length, $noSplit, $allowHtml);

instead of direct call of the helper.

The "..." on a new line are annoying

When we trunscate the text we should show that it is "incomplete".
Usual thing for such cases is to add '...'.

Ah, sorry, you mean "on new line". This probably due to space that may happen.
'string.truncate' with $allowHtml = true should fix the issue.

avatar drmenzelit
drmenzelit - comment - 2 Oct 2024

with $allowHtml = true should fix the issue

$item->displayIntrotext = HTMLHelper::_('string.truncate', $item->displayIntrotext, $introtext_limit, true, true);
Nope
grafik

Joomla has several truncate functions, I thought the one in Joomla\CMS\HTML\Helpers\StringHelper was working better than the other ones I found ...

avatar Fedik
Fedik - comment - 2 Oct 2024

I see. Well, that is tricky :)

avatar drmenzelit
drmenzelit - comment - 2 Oct 2024

I see. Well, that is tricky :)
you say it ;-)

avatar Fedik
Fedik - comment - 2 Oct 2024

Okay, I think what would be better, is to move the trunscating to the layout (out from the helper), then people can overide it. Who want HTML, or plain text.

avatar RickR2H
RickR2H - comment - 3 Oct 2024

Okay, I think what would be better, is to move the trunscating to the layout (out from the helper), then people can overide it. Who want HTML, or plain text.

I guess that the best way to go. An other wat is to make an extra option in the module settings. Plain/HTML intro text and keep it in the helper.

avatar conseilgouz conseilgouz - change - 4 Oct 2024
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2024-10-04 12:40:40
Closed_By conseilgouz
Labels Added: bug PR-5.2-dev
avatar conseilgouz conseilgouz - close - 4 Oct 2024

Add a Comment

Login with GitHub to post a comment