- Issue created by @bioschaf
- Assigned to shailja179
- Issue was unassigned.
- 🇮🇳India shailja179 India
@bioschaf,
I am using these settings given in screenshot. But it is working as expected.
Can you give the proper steps to reproduce the issue? I am using the same settings, I selected
[x] Display More link?
and
[x] Display More link only when content is trimmed?I don't think it is a problem with the settings of this module an how they work.
As I wrote the "SmartTrimFormatter.php" compares two variables ($output and $original_output) to determine if the "More"-Link should be added or not. In my case (whatever the reason may be) $original_output contains a newline character at the end, which is stripped by this module's function "truncateChars" in TruncateHTML.php, even if the content itself is not shortened.
- First commit to issue fork.
- 🇺🇸United States ultimike Florida, USA
@bioschaf,
Thanks for your report and efforts on this issue.
I have modified one of the test nodes in our existing SmartTrimFunctionalTest.php with a trailing "\r\n " - without any fix
testMoreLinkOnlyWhenContentIsTrimmed()
failed (good news!)I then removed the
trim($html)
bits from theTruncateHTML
service methods and moved them to the formatter. This ensures that both the $output and $original_output are trimmed equally. With this fix, all tests pass.MR created and assigned to @markie for review.
-mike
- Assigned to markie
- Status changed to Needs review
over 1 year ago 3:03pm 25 June 2023 - @ultimike opened merge request.
- First commit to issue fork.
- 🇺🇸United States ultimike Florida, USA
D9 test currently failing.
1) Drupal\Tests\smart_trim\Unit\TruncateHTMLTest::testRemoveHtmlComments ReflectionException: Trying to invoke protected method Drupal\smart_trim\TruncateHTML::removeHtmlComments() from scope ReflectionMethod /builds/project/smart_trim/tests/src/Unit/TruncateHTMLTest.php:190 /builds/project/smart_trim/vendor/phpunit/phpunit/src/Framework/TestResult.php:728 /builds/project/smart_trim/vendor/phpunit/phpunit/src/Framework/TestSuite.php:684 /builds/project/smart_trim/vendor/phpunit/phpunit/src/Framework/TestSuite.php:684 /builds/project/smart_trim/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:651 /builds/project/smart_trim/vendor/phpunit/phpunit/src/TextUI/Command.php:144 /builds/project/smart_trim/vendor/phpunit/phpunit/src/TextUI/Command.php:97 phpvfscomposer:///builds/project/smart_trim/vendor/phpunit/phpunit/phpunit:106
See https://git.drupalcode.org/project/smart_trim/-/jobs/58193 for full info.
-mike
- Assigned to ultimike
- Status changed to Needs work
over 1 year ago 9:25am 19 July 2023 - 🇺🇸United States ultimike Florida, USA
Turns out this was an easy fix - I had written the test for PHP 8.1+, which is why it failed the D9 test. MR updated.
-mike
- Assigned to markie
- Status changed to Needs review
over 1 year ago 1:02pm 19 July 2023 -
markie →
committed 48a42891 on 2.1.x authored by
ultimike →
Issue #3365797 by ultimike, markie, shailja179, bioschaf: Read more link...
-
markie →
committed 48a42891 on 2.1.x authored by
ultimike →
- Status changed to Fixed
over 1 year ago 2:47pm 3 August 2023 - 🇺🇸United States markie Albuquerque, NM
Merged. Thanks for all the good work
Automatically closed - issue fixed for 2 weeks with no activity.