Module: Alchemy::PgSearch::SearchHelper
- Defined in:
- app/helpers/alchemy/pg_search/search_helper.rb
Instance Method Summary collapse
- #highlighted_excerpt(text, phrase, radius = 50) ⇒ Object
-
#render_search_form(options = {}) ⇒ Object
Renders a search form.
-
#render_search_results(options = {}) ⇒ Object
Renders the search results partial within
app/views/alchemy/search/_results.html
.
Instance Method Details
#highlighted_excerpt(text, phrase, radius = 50) ⇒ Object
48 49 50 |
# File 'app/helpers/alchemy/pg_search/search_helper.rb', line 48 def highlighted_excerpt(text, phrase, radius = 50) highlight(excerpt(text, phrase, radius: radius).to_s, phrase) end |
#render_search_form(options = {}) ⇒ Object
Renders a search form
It queries the controller and then redirects to the search result page.
Example search results page layout
Only performs the search if ferret is enabled in your config/alchemy/config.yml
and a page is present that is flagged with searchresults
true.
# config/alchemy/page_layouts.yml
- name: search
searchresults: true # Flag as search result page
Note
The search result page will not be cached.
26 27 28 29 30 31 32 33 |
# File 'app/helpers/alchemy/pg_search/search_helper.rb', line 26 def render_search_form(={}) = { html5: false, class: 'fulltext_search', id: 'search' } render 'alchemy/search/form', options: .merge(), search_result_page: search_result_page end |
#render_search_results(options = {}) ⇒ Object
Renders the search results partial within app/views/alchemy/search/_results.html
40 41 42 43 44 45 46 |
# File 'app/helpers/alchemy/pg_search/search_helper.rb', line 40 def render_search_results(={}) = { show_result_count: true, show_heading: true } render 'alchemy/search/results', options: .merge() end |