Highlight to Search

:information_source: Summary Highlight text and search it quickly
:eyeglasses: Preview Theme Creator (To an example topic)
:hammer_and_wrench: Repository GitHub - NateDhaliwal/discourse-highlight-to-search · GitHub
:question: Install Guide How to install a theme or theme component
:open_book: New to Discourse Themes? Beginner’s guide to using Discourse Themes

Install this theme component

Overview

This component allows users to highlight text in posts and search for it quickly. Searches can be set to be the forum’s search, for an external search (e.g. Google).

Screenshots

Settings

search url: The URL path of the search function. You can use the %{selected_text} as a placeholder.

is external: Check this if the search is external, e.g. Google.

search exact: Check this to search for exactly the selected text.

search exact character: The character to denote an exact search. Defaults to ".

include from author: For a forum-wide search, you can check this to show posts only from the post author with the selected text.

The button text and title can be edited via locales.

9 likes

nicely done Nate! :clap:

you should fill in the github repo readme file tho :wink:

4 likes

Since you don’t know the link to the topic here in the forum until it’s been approved, it always takes me a while to edit the Readme, too. I’m not always online when my topic is published, and I wait to edit the file until I know the link.

4 likes

I have updated the readme, thanks for the reminder!

4 likes

When Is external is not enabled and no valid results are found from search, can the external search engine be freely defined? For example, replace Google with Bing.

That is currently not a feature. There isn’t a good way to check if no results are found, this merely redirects the user to the search page with the query.

Hmmm… What I mean is that regardless of the search accuracy, when asking whether to use external search, whether you can change the search engine, that doesn’t require doing anything to “check if no results” . Currently it is fixed to use Google, and I hope to replace it with another search engine.

1 like

I might be misunderstanding, so please correct me if I’m wrong.

The is_external setting has to be ticked if the search method used is not the forum search, like Bing or Google. This is so that the component will redirect the user accordingly.

You can change the search_url setting to bing.com/search?q=%{selected_text} to search via Bing. As long as the search engine has a way to interpolate the search query, you can type it in.

2 likes

Is your question about this interface from Discourse core?

There are other components to customize that, like Baidu Search and DuckDuckGo Search Suggestions

1 like

It’s not your fault. It’s that my test environment and production environment have a difference of several versions of Discourse, which made me mistakenly think that the prompt asking whether to use Google search when forum search yields no results was added by this theme component. :slightly_smiling_face: So it’s not only not your problem, but quite the opposite, it gives me an alternative solution to invoke external search from within the site. Well done. :grinning_face_with_smiling_eyes:

1 like

Thank you for sharing this information!