Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-06-13 20:39:54

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Disable search

I do not want to allow search on a site. Even though there is no search box on the site i occasionally get hits on urls with “q=some search term” which makes the page be empty. Is there a way to disable the search?


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#2 2008-06-13 21:10:24

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Disable search

You could display a message on empty search pages using <txp:if_search>. Or use this tag with zem_redirect to redirect them somewhere else.

Offline

#3 2008-06-14 10:40:02

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Disable search

Or at the top of your page:

<txp:php>unset($_GET['q']);</txp:php>

Offline

#4 2008-06-14 16:09:50

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Disable search

Thanks both for your suggestions. I went with ruud’s which makes my example from the initial post return a 404. Perfect.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#5 2008-06-14 16:17:53

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Disable search

ruud wrote:

Or at the top of your page:

<txp:php>unset($_GET['q']);</txp:php>

Ruud

can I assume that the same would work with ‘c’ instead of ‘q’?

Offline

#6 2008-06-14 17:15:36

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Disable search

@Els: sure, that works for all GET parameters.

Offline

#7 2008-06-14 18:31:39

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Disable search

Just being nosey Els, but why would you want it to work with “c”?


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#8 2008-06-14 18:58:28

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Disable search

Because I stopped using categories quite a while ago, and – though I’d been using /category/category-name URLs for ages – I’m still getting requests for ?c=blah pages sometimes. And they never give you a 404, only, just like the search in MattD’s example, an empty page. I’ve been using rewrite rules in .htaccess to avoid that, but a 404 would be better of course.

Offline

#9 2008-06-14 19:02:28

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Disable search

Doesn’t zem’s redirect plug-in work for that?


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#10 2008-06-14 20:49:52

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Disable search

Hmm… could be. But I never got it to work nicely with tru_tags.

Offline

Board footer

Powered by FluxBB