?
Related to # 16484
avatar vladav
vladav
5 Jul 2017

Steps to reproduce the issue

Use search box to find keyword in title

Expected result

yellow highlighted keyword

Actual result

" span class="highlight" keyword /span " (I had to remove <> to be able to show text)

System information (as much as possible)

Joomla updated to 3.7.3

Additional comments

On every Joomla instalation, after upgrade

Votes

# of Users Experiencing Issue
2/2
Average Importance Score
5.00

avatar vladav vladav - open - 5 Jul 2017
avatar joomla-cms-bot joomla-cms-bot - change - 5 Jul 2017
Title
Search results in title show <span class="highlight">search keyword</span> tag
Search results in title show search keyword tag
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 5 Jul 2017
avatar vladav vladav - change - 5 Jul 2017
The description was changed
avatar vladav vladav - edited - 5 Jul 2017
avatar vladav vladav - change - 5 Jul 2017
The description was changed
avatar vladav vladav - edited - 5 Jul 2017
avatar vladav vladav - change - 5 Jul 2017
The description was changed
avatar vladav vladav - edited - 5 Jul 2017
avatar dgt41
dgt41 - comment - 5 Jul 2017

The way that highlighter.js works is by wrapping the keyword with a <span class='highlight'>. Thus this is expected behaviour. You might need to adjust the way you're using the script or, maybe easier, the way the the title is displayed (e.g. preg_replace('<span...', '', $title);).

By the way where are you getting this? In core highlighter is used only for the search results AFAIK

avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Jul 2017
Category com_search
avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Jul 2017
Rel_Number 0 16484
Relation Type Related to
avatar joomla-cms-bot joomla-cms-bot - edited - 5 Jul 2017
avatar joomla-cms-bot joomla-cms-bot - change - 5 Jul 2017
Title
Search results in title show <span class="highlight">search keyword</span> tag
Search results in title show search keyword tag
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 5 Jul 2017

@vladav thanks for reporting.

Related to #16484?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16979.

avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Jul 2017
Status New Discussion
avatar vladav
vladav - comment - 5 Jul 2017

Yes, related to #16484. We will change code as per 35752ef and test it out.

avatar vladav
vladav - comment - 5 Jul 2017

Removing line 270 from components/com_search/views/search/view.html.php solved the issue. (Still, now the keyword in title is not highlighted, but it does not show html span tags).

avatar nicksavov
nicksavov - comment - 5 Jul 2017

Same issue here using a Shaper_helix3 template. Removing line 270 has provided a temporary fix.

avatar vladaaa13
vladaaa13 - comment - 6 Jul 2017

@vladav I remove line 270 and problem is gone, tnx :)

avatar alexfedorin
alexfedorin - comment - 11 Jul 2017

I have same issue Yootheme template.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16979.

avatar joomla-cms-bot joomla-cms-bot - close - 11 Jul 2017
avatar joomla-cms-bot joomla-cms-bot - change - 11 Jul 2017
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2017-07-11 09:04:00
Closed_By joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 11 Jul 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 11 Jul 2017
Closed_Date 2017-07-11 09:04:00 2017-07-11 09:04:01
Closed_By joomla-cms-bot franz-wohlkoenig
avatar joomla-cms-bot
joomla-cms-bot - comment - 11 Jul 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 11 Jul 2017

closed as having PR ##16484


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16979.

avatar nicksavov
nicksavov - comment - 14 Jul 2017

@franz-wohlkoenig isn't #16484 the source of the bug, rather than a fix for the bug?

avatar mahsite
mahsite - comment - 15 Jul 2017

سلام دوستان ایرانی
این مشکل در ورژن جدید جوملا واقع شده است
برای رفع این مشکل

به ادرس زیر بروید

public_html/components/com_search/views/search/view.html.php

و کد زیر را پیدا . غیر فعال نمایید با //

$result->title = StringHelper::str_ireplace($needle, $hl1 . $needle . $hl2, htmlspecialchars($result->title, ENT_COMPAT, 'UTF-8'));

موفق باشید

avatar wojsmol
wojsmol - comment - 16 Jul 2017

@mahsite Plese use English in this repo.

avatar rolandverhaar
rolandverhaar - comment - 18 Jul 2017

I have two websites.
One produces in HTML code:
<a href="/home/nieuws/12257-bloot-op-de-fiets-tijdens-de-world-naked-bike-ride"> Bloot op de fiets tijdens de <span class="highlight">world</span> Naked Bike Ride </a>
So, this is correct.
The other produces in HTML code:
<a href="/nieuws/14334-niet-meer-praten-tegen-de-praatpaal" title="Niet meer praten tegen de <span class=&quot;highlight&quot;> praatpaal </span> ">Niet meer praten tegen de &lt;span class="highlight"&gt; praatpaal &lt;/span&gt; </a>
This is incorrect, as it will show tags in the output.
Code base for both websites: Joomla! 3.7.3

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 18 Jul 2017

@nicksavov should ths Issue be reopened?

avatar rolandverhaar
rolandverhaar - comment - 19 Jul 2017

No, I think the problem is in the Warp framework.
Will have to resolve it there.

avatar nicksavov
nicksavov - comment - 19 Jul 2017

@franz-wohlkoenig Yes, I think so. The two sites I experienced this on had a custom template and a Helix 3 framework template.

avatar joomla-cms-bot joomla-cms-bot - reopen - 20 Jul 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 20 Jul 2017
Status Closed Discussion
Closed_Date 2017-07-11 09:04:01
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 20 Jul 2017
Status Discussion New
Closed_Date 0000-00-00 00:00:00
avatar joomla-cms-bot joomla-cms-bot - reopen - 20 Jul 2017
avatar joomla-cms-bot
joomla-cms-bot - comment - 20 Jul 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 20 Jul 2017

reopened as stated above.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16979.

avatar sc00zy
sc00zy - comment - 20 Jul 2017

I saw this on a few websites with templates that override com_search. Yootheme seem to have updated their templates to fix this.

avatar nicksavov
nicksavov - comment - 21 Jul 2017

Both templates here have an override for com_search. I could implement the fix in the overrides (wouldn't be an issue).

Is there a way to fix this in core for all users, including those that have template overrides? I'm guessing the answer is going to be no, but thought I'd ask

avatar brianteeman
brianteeman - comment - 21 Jul 2017

If the issue is in the override then nothing changed in the core will effect the override. Thats the whole point of an override.

Closing as it is not a core issue

avatar brianteeman brianteeman - change - 21 Jul 2017
Status New Closed
Closed_Date 0000-00-00 00:00:00 2017-07-21 16:02:30
Closed_By brianteeman
avatar brianteeman brianteeman - close - 21 Jul 2017
avatar INOSIM
INOSIM - comment - 25 Jul 2017

We also had this issue as described above. We found that we needed to fix our template override, as described under 35752ef. After fixing our template override, highlighting of the keyword in the title line worked allright. But still, the highlighted keyword is not displayed correctly. For example, if you enter a search like "joomla", and "Joomla" would be the correct writing in the title line, instead you see "joomla" highlighted in the title line. In the content snippet below the title line, though, you see the keyword in correct writing, e. g., "Joomla". Apparently, in the search result not the complete original string from the title line is displayed but the string from the search input is integrated here.

avatar premierinternet
premierinternet - comment - 25 Jul 2017

Try this to fix the case issue:
if(stripos(htmlspecialchars($result->title, ENT_COMPAT, 'UTF-8'),$needle) > 0){ $needlepos = stripos(htmlspecialchars($result->title, ENT_COMPAT, 'UTF-8'),$needle); $firstneedle = substr(htmlspecialchars($result->title, ENT_COMPAT, 'UTF-8'),$needlepos,1); if (ctype_upper($firstneedle)) { $needle = StringHelper::ucwords($needle); } }
Insert the code above in components/com_search/views/search/view.html.php at line 269 before $result->title = StringHelper::str_ireplace($needle, $hl1 . $needle . $hl2, htmlspecialchars($result->title, ENT_COMPAT, 'UTF-8'));
You will want to make this an override or it will disappear the next time you upgrade Joomla. The lines are referenced in Joomla 3.7.3

avatar INOSIM
INOSIM - comment - 26 Jul 2017

Thanks for taking the time to reply and trying to provide a fix. Sadly there are two problems though. First, the fix only works around case differences of the first character and more importantly second, isn’t the “view.html.php” part of the core and cannot simply be overridden contrary to e.g. the “default_results.php”?

avatar nicksavov
nicksavov - comment - 28 Jul 2017

If the issue is in the override then nothing changed in the core will effect the override.

Not exactly. Many things can change in the core and affect an override. The only thing that can change in core that for sure won't affect an override is the file that's being overridden.

In this particular case, the core change in components/com_search/views/search/view.html.php (which isn't getting overridden) affected the override (for components/com_search/views/search/tmpl/default_results.php).

avatar nicksavov
nicksavov - comment - 28 Jul 2017

First, the fix only works around case differences of the first character

Could you give an example?

Isn’t the “view.html.php” part of the core and cannot simply be overridden contrary to e.g. the “default_results.php”?

Yes, that's correct. It can be overriden (ex: with a plugin), but it's not as easy as a regular template override.

avatar nicksavov
nicksavov - comment - 28 Jul 2017

re: example:

Looks like that's fixed with #17303

avatar INOSIM
INOSIM - comment - 31 Jul 2017

Thanks!

avatar nicksavov
nicksavov - comment - 8 Aug 2017

Can this issue be reopened please?

avatar joomla-cms-bot joomla-cms-bot - change - 8 Aug 2017
Status Closed New
Closed_Date 2017-07-21 16:02:30
Closed_By brianteeman
avatar joomla-cms-bot joomla-cms-bot - reopen - 8 Aug 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 8 Aug 2017
Status New Discussion
Closed_Date 0000-00-00 00:00:00
avatar joomla-cms-bot
joomla-cms-bot - comment - 8 Aug 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 8 Aug 2017

reopened as stated above.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16979.

avatar brianteeman
brianteeman - comment - 8 Aug 2017

why is this re-opened

avatar nicksavov
nicksavov - comment - 10 Aug 2017

Thanks!

It shouldn't have been closed. See #16979 (comment) for more info.

avatar mbabker
mbabker - comment - 10 Aug 2017

I'm missing something then. What is left for us to do to address this issue? Introducing a new property does not fix overrides because overrides will be unaware of it, reverting to the old way restores a bug. At this point it is unclear what the issue to be resolved is.

avatar nicksavov
nicksavov - comment - 10 Aug 2017

Good question! This part needs to be addressed:

Is there a way to fix this in core for all users, including those that have template overrides? I'm guessing the answer is going to be no, but thought I'd ask

As to the old way, I wouldn't call it bug per se. It's a design choice of whether to highlight the search word in the title or not. That design choice has likely been there since the plugin was first added to core. For that reason, some would consider highlighting the title as a nice new feature, rather than a bug fix.

avatar brianteeman
brianteeman - comment - 10 Aug 2017

If we are highlighting matching search terms and we are searching for those terms in the title then it was a bug that they were not highlighted before. That bug has been fixed. There is nothing that can be changed in the core to make your override with a bug work correctly

avatar mbabker
mbabker - comment - 10 Aug 2017

Then the answer is no. If you change something in a layout, that is specific to that layout. If you change something in the data objects being fed into a layout, it is a global change affecting anything using that data object.

avatar rolandverhaar
rolandverhaar - comment - 10 Aug 2017

In the core, the Title of an article is not put through any html-encoding. Therefore the handling of the title string is left to the template or override. Now the title string is changed in the core and overrides or templates do not expect this.
Naturally it can be fixed in the override, however, it would be nice if all data objects are treated the same (preferably do nothing in the core), then all overrides and templates can handle all objects the same way.
A bug that has ben around for ages is not a bug anymore.

avatar nicksavov
nicksavov - comment - 10 Aug 2017

@mbabker thanks!

avatar brianteeman
brianteeman - comment - 10 Aug 2017

So can we close it now?

avatar ReLater
ReLater - comment - 12 Aug 2017

@rolandverhaar

In the core, the Title of an article is not put through any html-encoding. Therefore the handling of the title string is left to the template or override. Now the title string is changed in the core and overrides or templates do not expect this.

You have to remove the escape thing from your template overrides NOT because the title has been htmlspecialchared in core but because parts of the title are surrounded sometimes by HTML-SPAN-tags to highlight search hits.

I think removing the highlightning of titles is not an option at all.

So, yes, please close this issue.

avatar franz-wohlkoenig franz-wohlkoenig - change - 13 Aug 2017
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2017-08-13 04:35:50
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 13 Aug 2017
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 13 Aug 2017
avatar joomla-cms-bot
joomla-cms-bot - comment - 13 Aug 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 13 Aug 2017

closed as stated above.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16979.

avatar ittoufiq
ittoufiq - comment - 19 Sep 2017

Hi,
Please enter the file location
templates/Your_template/html/com_search/search/default_results.php

Please open the file default_results.php And find out the code

<a href="<?php echo JRoute::_($result->href); ?>"<?php if ($result->browsernav == 1) :?> target="_blank"<?php endif;?>>
<?php echo $this->escape($result->title);?>
</a>

And replace with this code

<a href="<?php echo JRoute::_($result->href); ?>"<?php if ($result->browsernav == 1) : ?> target="_blank"<?php endif; ?>>
<?php // $result->title should not be escaped in this case, as it may ?>
<?php // contain span HTML tags wrapping the searched terms, if present ?>
<?php // in the title. ?>
<?php echo $result->title; ?>
</a>

-Thanks

avatar ZerooCool
ZerooCool - comment - 21 Oct 2017

Resolved with the ittoufiq method.

Translate to french :

Résolu avec la méthode de ittoufiq.
highlight affiche des balises span dans les titres des résultats de la recherche :
https://www.visionduweb.eu/wiki/index.php?title=JSN_Artista_Free#highlight_affiche_des_balises_span_dans_les_titres_des_résultats_de_la_recherche

avatar oisvidi
oisvidi - comment - 23 Nov 2017

My fix in /components/com_search/views/search/view.html.php on line 162 insert code "break;"

avatar QuotesUK
QuotesUK - comment - 19 Jul 2018

I have this issue in Joomla v3.8.10

I know that previous discussion has explained how to fix this but without the context of surrounding code fragments for a "before" and "after" it is difficult working out what I need to do. Some authors have refered to modifying two files, and others in different places. Where exactly - line 19, 20, 162 or 270?

For example my file (v3.8.10) com_search/views/search/view.html.php line 162...
$result->title = $rowTitleHighLighted;

For example my file (v3.8.10) com_search/views/search/view.html.php line 270...
ksort($posCollector);

I would appreciate it someone could provide clear guidance of what is being changed and perhaps make it future proof by showing several of the existing lines of code before and after, to help us locate it. Thank you.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16979.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 19 Jul 2018

@QuotesUK please open a new Issue (and link to this Issue) as Comments on closed Issues didn't get much Notice, thanks.

avatar rpmconsulting
rpmconsulting - comment - 31 Jan 2019

I'm having this issue in Joomla 3.9.2. What ultimately fix's the showing up as header in search results?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16979.

avatar sc00zy
sc00zy - comment - 4 Feb 2019

I'm having this issue in Joomla 3.9.2. What ultimately fix's the showing up as header in search results?

This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16979.

You need to update the template override of the template you're using

avatar rpmconsulting
rpmconsulting - comment - 5 Feb 2019

Do you have the info/instructions on how to do the override?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/16979.

avatar sc00zy
sc00zy - comment - 5 Feb 2019

It depends on the template you are using. You can read more about template overrides here https://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core

Add a Comment

Login with GitHub to post a comment