Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-06-17 06:17:00

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

Section specific search not working on 4.8.1

Has section specific search stopped working? We used to be able to search for http://www.domain.tld/?m=any&q=query&s=mysection and only get results from that section. Using the query, txp now returns results from all sections.

> Edited to add that the issue also appears on the demo site.

How to reproduce in the demo site:

  1. Create a section called Test
  2. Create a new article and in the body write tutorials and allocate that article in the test section.
  3. The following should have returned just the one article in the test section but it returns both existing articles: https://release-demo.textpattern.co/?m=any&q=tutorials&s=test

> Edit 2: Submitted issue on github

Last edited by colak (2020-06-17 06:39:18)


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 2020-06-17 10:07:18

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

Re: Section specific search not working on 4.8.1

colak wrote #323799:

Has section specific search stopped working? We used to be able to search for http://www.domain.tld/?m=any&q=query&s=mysection and only get results from that section. Using the query, txp now returns results from all sections.

Hi Yiannis,

there is no evidence txp search ever worked as you describe. I’ve got an old 4.5.7 site where searching for ?s=etc&q=txp returns the matching articles from all sections. Same on 4.7.2 demo site. Are you sure search filtering by section was ever possible? This said, it sounds logical…

Offline

#3 2020-06-17 11:33:30

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

Re: Section specific search not working on 4.8.1

etc wrote #323806:

there is no evidence txp search ever worked as you describe.

I was doing some digging and came to the same conclusion…

This said, it sounds logical

… and this conclusion too! It’d be a handy feature, even if the search has to be constructed by hand and we allow context to be passed forward.

The main issue as I see it is that when you construct a txp:search_input tag, the section attribute is already taken to indicate the section upon which you wish the results to land. So we’d need a sections attribute (or something) to indicate which site sections would return results from that tag.

Presumably, this would override any ‘Searchable’ values set when the section is defined from the Sections panel? Or add to it? Or somehow allow you to pick whether it adds to or replaces the built-in Searchable flag.

Whatever we choose, that does give us some nice flexibility to offer ‘advanced’ searches that could search “hidden” (or otherwise unreachable by URL) sections such as, oooh, let’s see, pageless sections perhaps? Thus, you could have a public facing search for visitors but, perhaps if logged in or if you visit a special section, permit a secondary search from the front end for articles that also includes pageless or ‘draft’ sections that you use as a staging area.

If this concept works, could we sneak it into 4.8.2?

Last edited by Bloke (2020-06-17 11:38:00)


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

#4 2020-06-17 14:29:51

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

Re: Section specific search not working on 4.8.1

It might have been a construct from Netcarver when he helped us have a common search box for all our installs.

The php and ths js used to do the job. It would be a great feature though:)


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

Offline

#5 2020-06-18 14:50:42

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

Re: Section specific search not working on 4.8.1


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

Offline

#6 2020-07-16 17:47:28

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: Section specific search not working on 4.8.1

I am making a template based on a one-page site that pulls in content from articles written in the archive section which is pageless. Because it’s a long page I thought I’d put a search form in there.

The search finds content in the archive section and produces the usual search results with a clickable title. When clicked, of course, there’s a 404 not found, unknown section. Search does not produce any content from the home page (which is made entirely of pulled in content). I used wet_haystack to search excerpts that aren’t included on the home page, in case you’re wondering how I know.

It would be great if search could be limited to the home page, in my case.


BB6 Band My band
Gud One My blog

Offline

#7 2020-07-16 19:26:54

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

Re: Section specific search not working on 4.8.1

zero wrote #324599:

It would be great if search could be limited to the home page, in my case.

You mean, only visible text must be searchable? Then it is not txp but js thing, a bit like Cmd/Ctrl+F works (see e.g. here).

This said, the standard txp search should work too, you just have to remove <txp:permlink /> from search_results form.

Offline

#8 2020-07-16 19:31:51

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

Re: Section specific search not working on 4.8.1

zero wrote #324599:

search finds content in the archive section and produces the usual search results with a clickable title. When clicked, of course, there’s a 404 not found, unknown section.

Hmmm. I think if you’re using a search that might return article from pageless sections, you’ll need to tweak the search_results form yourself instead of using the default. Maybe something like this:

<txp:if_article_section name="pageless_section">
   <txp:link_to_home><txp:title /></txp:link_to_home>
<txp:else />
   <txp:permlink><txp:title /></txp:permlink>
</txp:if_article_section>

At least then, any hits to the pageless content will bounce to the front page. You could enhance that by jumping to the page fragment #id too, if you know which area of the page it resides.


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 2020-07-16 20:16:18

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: Section specific search not working on 4.8.1

Thanks both. I’m asking myself why would anyone want to search on this page? If they are looking for something in particular, why come to my page? If they come to my page I want them to read it from the top. If they are returning to the page, I think they’ll find what they are looking for by using the in-page nav. So Crtl + F it is.

Of course, it’s becoming a template so I don’t know how others will use it. With ALL content being pageless, it’s pointless just redirecting them to the front page, so just removing the permlink is probably what I’ll do, so they can see their search term in context. Cheers!


BB6 Band My band
Gud One My blog

Offline

#10 2020-07-16 20:22:42

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

Re: Section specific search not working on 4.8.1

BTW, <txp:article searchall="0" /> seems to solve the OP problem.

Offline

#11 2020-07-17 03:20:30

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,599
GitHub Twitter

Re: Section specific search not working on 4.8.1

Yes. You’re right Oleg.

I’m using <txp:article searchall="0" /> to search specifically into some different sections for my latest project. All is perfect as espected! 😉


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

Board footer

Powered by FluxBB