Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

last letter truncated in the titles of search results #7

Open
galamarco opened this issue Jan 17, 2022 · 2 comments · May be fixed by zzella/search#1 or #9
Open

last letter truncated in the titles of search results #7

galamarco opened this issue Jan 17, 2022 · 2 comments · May be fixed by zzella/search#1 or #9

Comments

@galamarco
Copy link

Steps to reproduce the issue

  • Please write some articles with a log and small title.
  • Go to search an article and you will see a title of article with last letter truncated.
    This is an image

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
Copy link

zzella commented Apr 4, 2022

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.

zzella added a commit to zzella/search that referenced this issue Apr 4, 2022
Fixes the issue of apostrophes in an article titles causing the title to be truncated in search results. 
Resolves joomla-extensions#7 (joomla-extensions#7)
Resolves joomla/joomla-cms#34724 (joomla/joomla-cms#34724)
Work around is to not run titles through search preparation which truncates text around the search term. Titles are returned in full instead - which is the expected behavior for search results (a user wants to see the title of an article not an extract of the title).
This was referenced Apr 4, 2022
@woluweb
Copy link

woluweb commented Nov 18, 2022

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 ?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants