CMSimple XH version 1.7.2 Search [Workaround and Extention]

Third Party Plugins to CMSimple - how to install, use and create plugins

Moderator: Tata

Post Reply
simpleSolutions.dk
Posts: 151
Joined: Thu Oct 06, 2011 7:00 am

CMSimple XH version 1.7.2 Search [Workaround and Extention]

Post by simpleSolutions.dk » Mon Nov 05, 2018 10:57 am

This is a workoraund for the highlight bug in search function (viewtopic.php?f=10&t=14178|) in CMSimple XH version 1.7.2 ONLY.

Instead of inserting extra tags to highlight search results, keywords are highlighted with javascript.

Now, when I started correcting the search function, I also expanded the class Search in file Serch.php in core CMSimple with sorted results list.

Sorted result list has the following order:
1 exact match
2 All keywords are found on the page
3 only some keywords are found on the page

And finally, if search has only one result, the extended version redirects to the actual page with keywords instead of displaying a result page with link to the page. This work fine with javascript highlights as javascript scroll the page to the first hit.

Changes to the core code will of course be overwritten by the next update of CMSimple XH. By that time, I hope that the the bug is corrected and that the development team implements the extension to the search function itself. The development team is of course welcome to use my code.

Followed files are changed:
tlpfunc.php
Search.php

Download: https://simplesolutions.dk/?SearchHi

lck
Posts: 1364
Joined: Wed Mar 23, 2011 11:43 am
Contact:

Re: CMSimple XH version 1.7.2 Search [Workaround and Extention]

Post by lck » Mon Nov 05, 2018 7:16 pm

Hi Jerry,

in your website https://simplesolutions.dk/ the workoraand already seems to be implemented, right?
I tested the search there once, works well, also the direct forwarding to the page, if the search has only one result.

There is one problem. I know normally no one would ever search for a protected space, but I did it with the following result.
1. https://example.com/?search=%C2%A0&function=search
2. the page "Result of your search" is displayed
3. if you now click on a link in the result list, this page will be loaded, but the page freezes, no action possible :? .
After about 40 seconds a popup appears with the message "Seite reagiert nicht ...".
The popup disappears after a few minutes and a blank white page is displayed.
Last edited by cmb on Mon Nov 05, 2018 11:01 pm, edited 1 time in total.
Reason: Change problematic link
„Bevor du den Pfeil der Wahrheit abschießt, tauche die Spitze in Honig!“   👉 Ludwig's XH-Templates for MultiPage & OnePage

simpleSolutions.dk
Posts: 151
Joined: Thu Oct 06, 2011 7:00 am

Re: CMSimple XH version 1.7.2 Search [Workaround and Extention]

Post by simpleSolutions.dk » Mon Nov 05, 2018 7:43 pm

Well, that's right my site is running extended search.
This is a workaround and I can live with a freezing page after search for protected space.

cmb
Posts: 12893
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: CMSimple XH version 1.7.2 Search [Workaround and Extention]

Post by cmb » Tue Nov 06, 2018 12:18 pm

simpleSolutions.dk wrote:
Mon Nov 05, 2018 10:57 am
Instead of inserting extra tags to highlight search results, keywords are highlighted with javascript.

Now, when I started correcting the search function, I also expanded the class Search in file Serch.php in core CMSimple with sorted results list.

Sorted result list has the following order:
1 exact match
2 All keywords are found on the page
3 only some keywords are found on the page

And finally, if search has only one result, the extended version redirects to the actual page with keywords instead of displaying a result page with link to the page. This work fine with javascript highlights as javascript scroll the page to the first hit.
All in all, I like these improvements. However, according to SemVer patches should contain only backward-compatible bug fixes, but no new features. Since only the currently broken highlighting would qualify as bug, I would suggest to postpone the other improvements to XH 1.8.0.

I'm inclined to suggest to do the insertion of the <span class="xh_find"> with JS instead of PHP for XH 1.7.3. However, it seems we'd only need a small bit of searchhi.js to do this.
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

cmb
Posts: 12893
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: CMSimple XH version 1.7.2 Search [Workaround and Extention]

Post by cmb » Tue Nov 06, 2018 3:50 pm

cmb wrote:
Tue Nov 06, 2018 12:18 pm
I'm inclined to suggest to do the insertion of the <span class="xh_find"> with JS instead of PHP for XH 1.7.3. However, it seems we'd only need a small bit of searchhi.js to do this.
I think merging https://github.com/cmsimple-xh/cmsimple-xh/pull/373 would be appropriate for XH 1.7.3.

PS: I've noticed that we basically loose our testHighlightSearchWords() unit tests. :(
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

Post Reply