joomla-extensions / search

Legacy Search for Joomla
GNU General Public License v2.0
2 stars 6 forks source link

last letter truncated in the titles of search results #7

Open galamarco opened 2 years ago

galamarco commented 2 years ago

Steps to reproduce the issue

I thought it was a template bug and I reported the problem to Yootheme but the support verified that even with the Cassiopea template the code output is incorrect and for this reason the title is shown without the last letter. I try to change template in Cassiopea and the problm is the same.

The problem does not happen with short titles

Expected result

Titles in search results must be integers

Actual result

The last character of the search results title with a long title is deleted

System information (as much as possible)

Joomla 4.0.5 PHP 7.4.27 db mysql 10.3.32-MariaDB-cll-lve

Additional comments

You che see the problem on this page where first result have a title without the last character. If you open the article you will see that the last word has an extra letter.

zzella commented 2 years ago

This happens when there is an apostrophe in the title. The article title returned by com_search is truncated by the number of apostrophes in the title.

The letters are stripped in the search helper prepareSearchContent() function which calls _smartSubstr().

The prepareSearchContent() function is intended to return a substring which contains the search word. This makes sense to return a relevant extract from the article, but doesn't make sense on for the title. A title should just be returned in full, allowing the template to truncate it for length if necessary.

Proposed solution: Update components/com_search/views/search/view.html.php so that titles are not passed through the prepareSearchContent() function.

woluweb commented 1 year ago

Hi, Txs very very much @galamarco for reporting this and @zzella for proposing a fix!

I have tested it successfully :) (how comes this was not merged btw ?)