Use search box to find keyword in title
yellow highlighted keyword
" span class="highlight" keyword /span " (I had to remove <> to be able to show text)
Joomla updated to 3.7.3
On every Joomla instalation, after upgrade
Title |
|
||||||
Labels |
Added:
?
|
Category | ⇒ | com_search |
Rel_Number | 0 | ⇒ | 16484 |
Relation Type | ⇒ | Related to |
Title |
|
@vladav thanks for reporting.
Related to #16484?
Status | New | ⇒ | Discussion |
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).
Same issue here using a Shaper_helix3 template. Removing line 270 has provided a temporary fix.
I have same issue Yootheme template.
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-07-11 09:04:00 |
Closed_By | ⇒ | joomla-cms-bot |
Closed_Date | 2017-07-11 09:04:00 | ⇒ | 2017-07-11 09:04:01 |
Closed_By | joomla-cms-bot | ⇒ | franz-wohlkoenig |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/16979
closed as having PR ##16484
@franz-wohlkoenig isn't #16484 the source of the bug, rather than a fix for the bug?
سلام دوستان ایرانی
این مشکل در ورژن جدید جوملا واقع شده است
برای رفع این مشکل
به ادرس زیر بروید
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'));
موفق باشید
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="highlight"> praatpaal </span> ">Niet meer praten tegen de <span class="highlight"> praatpaal </span> </a>
This is incorrect, as it will show tags in the output.
Code base for both websites: Joomla! 3.7.3
@nicksavov should ths Issue be reopened?
No, I think the problem is in the Warp framework.
Will have to resolve it there.
@franz-wohlkoenig Yes, I think so. The two sites I experienced this on had a custom template and a Helix 3 framework template.
Status | Closed | ⇒ | Discussion |
Closed_Date | 2017-07-11 09:04:01 | ⇒ | |
Closed_By | franz-wohlkoenig | ⇒ |
Status | Discussion | ⇒ | New |
Closed_Date | 0000-00-00 00:00:00 | ⇒ |
Set to "open" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/16979
reopened as stated above.
I saw this on a few websites with templates that override com_search. Yootheme seem to have updated their templates to fix this.
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
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
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-07-21 16:02:30 |
Closed_By | ⇒ | brianteeman |
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.
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
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”?
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).
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.
Thanks!
Can this issue be reopened please?
Status | Closed | ⇒ | New |
Closed_Date | 2017-07-21 16:02:30 | ⇒ | |
Closed_By | brianteeman | ⇒ |
Status | New | ⇒ | Discussion |
Closed_Date | 0000-00-00 00:00:00 | ⇒ |
Set to "open" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/16979
reopened as stated above.
why is this re-opened
Thanks!
It shouldn't have been closed. See #16979 (comment) for more info.
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.
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.
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
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.
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.
So can we close it now?
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.
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-08-13 04:35:50 |
Closed_By | ⇒ | franz-wohlkoenig |
Closed_By | franz-wohlkoenig | ⇒ | joomla-cms-bot |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/16979
closed as stated above.
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
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
My fix in /components/com_search/views/search/view.html.php on line 162 insert code "break;"
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.
I'm having this issue in Joomla 3.9.2. What ultimately fix's the showing up as header in search results?
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
Do you have the info/instructions on how to do the override?
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
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