Search box in custom (404) page

(OG) #1


is it possible to add somehow visible prominent search box to custom e.g. 404 page? I see there is google search now, but I would like to replace it with internal site search. Is there any reason why offer google box there instead of internal search?

I’d just like to hack a box with GO button which will redirect to full page search results.

Thanks for input…

I’ve found this code for Handlebars… using component search-text-field.js.es6

    <div class="search row clearfix">
      {{search-text-field value=searchTerm class="full-page-search input-xxlarge search no-blur" action="search" hasAutofocus=hasAutofocus}}
      {{d-button action="search" icon="search" class="btn-primary" disabled=searchButtonDisabled}}

Seems like this should be pretty easy… After placing this into custom template, the only thing that seems to be missing is “search” action defined on template’s controller which will redirect the search into full page search… Any clues?

(OG) #2

Is there any simple way to put search text field to some other page than full page search? Thanks in advance.

[update]Simplest way I’ve found is to use {{search-text-field}} component in custom handlebars template and then define search action on controller:

import DiscourseURL from 'discourse/lib/url';

export default Ember.Controller.extend({
  actions: {
    search() {
      let searchTerm = this.get('searchTerm');
      DiscourseURL.routeTo('/search?q=' + searchTerm); 

Is there any way to modify default text (search topics, posts, users or categories):

(Dave McClure) #3

I think this was mainly left over from a time when internal site search was not nearly as good as it is now.

Internal search would be a better default here now, IMHO. Especially for sites that are not public :slight_smile:

(OG) #4

Exactly… I see the power of search filtering (in:wiki, …) as killer feature in Discourse… I’d absolutely agree with using internal search whenever possible.

(OG) #5

After some time I still wonder if internal search (instead of google search) could or should be included in custom 404 - not found - page… What are your opinions…?

I like sites that extract sensible text from requested url and prefill search query box with it… Currently this is done in google search box and only for /t/ links so this could be improved strongly… What is your opinion about extending it to all types of urls…?

(Neal Magee) #6

I’m seeing this topic now – only because I just bumped into the “Google” search box on the 404 page, which no longer makes sense now (especially for our site which is private behind an SSO provider and not visible to Google).

I would vote for moving to the regular internal search.

(Jeff Atwood) #7

If your site is login required that search should be disabled, follow up with @techAPJ

(Arpit Jalan) #8

I can confirm this. This change was made ~3 years ago.

(OG) #11

Any chance google search could be replaced by internal search? Internal search is very powerful imho and you can loose visitors via google search.

(Neal Magee) #12

@techAPJ Our Discourse has login_required checked in the settings, with SSO enabled, and yet if I go to a fictitious page to trigger the 404, I get this with Google search intact. We are running 1.8.0.beta12+60

(Jeff Atwood) #13

Yes that seems like a bug @techapj can you verify?

(Arpit Jalan) #14

I am not able to repro this with login required (and SSO) enabled locally or on a hosted instance. Can you PM me the URL of your forum so that I can look into it?


@Overgrow and @nmagee, did you ever get this solved? I’m also getting a Google search box on my 404 page on a site with login required and SSO enabled. Curious what you might have ended up doing to fix.