Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2025-01-08 10:32:21

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,116
Website GitHub Mastodon Twitter

search results: bug of feature?

I added some gibberish text for tests I am doing and described on forum.textpattern.com/viewtopic.php?pid=338662#p338662. As it takes longer than I expected to solve the issue, I have earlier today wrapped the text in <txp:if_logged_in>aaaab</txp:if_logged_in>, but txp actually still returns one result. Initially, I thought that this was because of my cache but I also checked it in Tor Browser and the result is there.

I would expect that anything wrapped in if_logged_in would not be visible. Up to now, I only used the tag in pages not articles, and I can understand why the result is returned, but is this actually a correct functionality? The same issue occurs when something is wrapped in txp:hide.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#2 2025-01-08 15:57:56

etc
Developer
Registered: 2010-11-11
Posts: 5,272
Website GitHub

Re: search results: bug of feature?

colak wrote #338717:

The same issue occurs when something is wrapped in txp:hide.

Yiannis, are you sure to edit the right page/form?

Offline

#3 2025-01-08 17:34:27

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,116
Website GitHub Mastodon Twitter

Re: search results: bug of feature?

etc wrote #338721:

Yiannis, are you sure to edit the right page/form?

My if_logged_in and hide tags are inside an article, and the results are returned, admittedly without showing the ‘hidden words.’ Tested it also in the textpattern demo site by adding <txp:hide>aaaaaa</txp:hide> in the one default article that comes with it and then searched for aaaaaa but also for hide. Easy to test.

As I reported before, I can understand why, but is this something we can programme against? ie do not return any articles in the front end search results for words enclosed in hide tags and only return articles with keywords enclosed in if_logged_in tags for those who are logged in.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#4 2025-01-08 18:46:58

etc
Developer
Registered: 2010-11-11
Posts: 5,272
Website GitHub

Re: search results: bug of feature?

colak wrote #338723:

do not return any articles in the front end search results for words enclosed in hide tags and only return articles with keywords enclosed in if_logged_in tags for those who are logged in.

Ah. This would be too expensive, since we’d need to parse each body/excerpt before scanning it by search. The best you can presently do is including all ‘hidden’ content via forms or other tags, I think.

Offline

#5 2025-01-09 09:36:01

kuopassa
Plugin Author
From: Porvoo, Finland
Registered: 2008-12-03
Posts: 241
Website

Re: search results: bug of feature?

How about a regex that checks if search result contains <txp:hide>something</txp:hide> or <txp:if_logged_in>something</txp:if_logged_in> (and their short-tag variants), then just hide those tags from search results and what’s between them?

Offline

#6 2025-01-09 11:19:17

etc
Developer
Registered: 2010-11-11
Posts: 5,272
Website GitHub

Re: search results: bug of feature?

That looks a bit complicated, since

  • presently, <txp:hide /> does not only serve to hide things, but also to postpone processing to the next parser pass
  • <txp:if_logged_in /> has also group and name attributes to respect
  • other tags (plugins?) might also contain some ‘hidden’ content, so the problem remains
  • more important, hiding does not prevent the match detection

A plugin to replace <txp:search_result_excerpt />, maybe?

Offline

#7 2025-01-09 13:30:52

etc
Developer
Registered: 2010-11-11
Posts: 5,272
Website GitHub

Re: search results: bug of feature?

We could, though, parse article body before highlighting search terms. This would effectively hide all ‘hidden’ content, but still not prevent it from matching search queries. Better than nothing?

Offline

#8 2025-01-09 14:44:21

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,498
Website GitHub

Re: search results: bug of feature?

Happy to try that if it doesn’t break too many existing site searches.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#9 2025-01-09 15:17:19

etc
Developer
Registered: 2010-11-11
Posts: 5,272
Website GitHub

Re: search results: bug of feature?

Bloke wrote #338730:

Happy to try that if it doesn’t break too many existing site searches.

It wouldn’t alter search results, just hide ‘hidden’ content in <txp:search_result_excerpt /> output. Easy to do, but possible ramifications make me hesitate. And it wouldn’t solve the OP problem anyway, as I get it.

Offline

Board footer

Powered by FluxBB