Advanced Header Search

Looks like there was another update that needed to be installed. It’s working fine now. Thanks!

EDIT: Question - once a topic page is opened I noticed that the header search bar disappears and instead the regular search icon shows up next to the profile icon. Is that expected?

2 Likes

Yep, that is expected. We have to account for possible long titles in topics competing for room in the header.

1 Like

Hello

I’m having trouble understanding how to use the parameters.

Would it be possible to have an example?

An icon to launch a search in a specific category?

Thanks for your help.

Hi!

It seems like the shortcuts for search doesn’t work with this component.

image

Is it something intended? Can that be fixed?

1 Like

Hey @Stephane_Roy,

Sorry I didn’t see this earlier. From memory, Penar did most of the work on this, but I wrote the spec so can answer most of your questions about this functionality. Feel free to nudge me here if you have more questions :slight_smile:

Below is an example of what I did inside our Gitlab Category. You can see in our header search bar that as soon as we type a search term(in this case pipeline) you can search the gitlab forum(clicking comments button), the gitlab docs(book), the gitlab project(ticket), and gitlab python libraries.

image

Below is an example of the params which lets you search the gitlab forum.

params value
prefix https://forum.gitlab.com/
icon comments
target _blank
showInCategories 20,33,90

The Params, as far as I remember are

params value
prefix domain url with forward slash
icon name of the svg icon. You can use fontawesome icons, or custom icons
target
showInCategories list of category IDs which the icon should appear in
excludeFromCategories Show the icon in every category except this list of categories

:warning: use only one of either showInCategories or excludeFromCategories

Below is one of the related commits are from March to April 2023 give or take. The test case is a pretty good example too:
DEV: Add test case by pmusaraj · Pull Request #23 · discourse/discourse-header-search · GitHub

2 Likes

@awesomerobot is this component super ceded by the Welcome banner? When I enable this I get two search bars in the title

Yeah there’s a note in the original post now

1 Like

Could you please elaborate, what is an external search, it’s not clear in the first post. I thought this just allows you to customize the icons. Does it search an external site like google or bing?

the button you’re assigning the icon to will on click direct to the host and path as per admin settings, but query as per what the user has put in the search header at the time :slightly_smiling_face:

remember a URL is made up of host then path then query

2 Likes

Exactly this :slight_smile:

When we commissioned this development the goal was to enable staff in our discourse to search multiple platforms from one search bar. Now users can search our Discourse, and Stackoverflow, and Sharepoint etc from the Discourse searchbar.

In this example “external search” would be stackoverflow or sharepoint. It doesn’t technically search those platforms, rather it redirects the user to the search results on those platforms.

1 Like