Algolia integration #490
Replies: 1 comment
-
just finished integration with Algolia, sharing sample code SET spoken_languages_title = COALESCE((SELECT translation_value FROM language WHERE translation_key='meta.spoken_languages' AND language_code=$lang), 'Spoken Language');
SET content_language_title = COALESCE((SELECT translation_value FROM language WHERE translation_key='search.text_language' AND language_code=$lang), 'Content Language');
SET live_translation_title = COALESCE((SELECT translation_value FROM language WHERE translation_key='search.live_translation' AND language_code=$lang), 'Live Translation');
SET event_type_title = COALESCE((SELECT translation_value FROM language WHERE translation_key='meta.category' AND language_code=$lang), 'Event Type');
SET transcript_title = COALESCE((SELECT translation_value FROM language WHERE translation_key='meta.text_status' AND language_code=$lang), 'Transcript');
SET subtitles_title = COALESCE((SELECT translation_value FROM language WHERE translation_key='search.subtitles' AND language_code=$lang), 'Subtitles');
SET location_title = COALESCE((SELECT translation_value FROM language WHERE translation_key='meta.location' AND language_code=$lang), 'Location');
SET year_title = COALESCE((SELECT translation_value FROM language WHERE translation_key='table.date.header' AND language_code=$lang), 'Year');
SELECT
'html' as component,
'
<div id="search-box" data-app-id="' || sqlpage.environment_variable('ALGOLIA_APP_ID') || '" data-search-key="' || sqlpage.environment_variable('ALGOLIA_SEARCH_KEY') || '" data-search-query="' || $search || '"></div>
<!-- Clear filters button -->
<div style="margin: 15px 0;">
<div id="clear-filters"></div>
</div>
<!-- Filter containers -->
<div style="display: flex; flex-wrap: wrap; gap: 20px; margin: 20px 0;">
<div style="min-width: 150px;">
<h4 style="margin: 0 0 10px 0; font-size: 14px;">' || $spoken_languages_title || '</h4>
<div id="spoken-language-filter"></div>
</div>
<div style="min-width: 150px;">
<h4 style="margin: 0 0 10px 0; font-size: 14px;">' || $content_language_title || '</h4>
<div id="content-language-filter"></div>
</div>
<div style="min-width: 150px;">
<h4 style="margin: 0 0 10px 0; font-size: 14px;">' || $live_translation_title || '</h4>
<div id="live-translation-filter"></div>
</div>
<div style="min-width: 120px;">
<h4 style="margin: 0 0 10px 0; font-size: 14px;">' || $event_type_title || '</h4>
<div id="recorded-event-filter"></div>
</div>
<div style="min-width: 150px;">
<h4 style="margin: 0 0 10px 0; font-size: 14px;">' || $transcript_title || '</h4>
<div id="transcript-filter"></div>
</div>
<div style="min-width: 150px;">
<h4 style="margin: 0 0 10px 0; font-size: 14px;">' || $subtitles_title || '</h4>
<div id="subtitles-filter"></div>
</div>
<div style="min-width: 200px;">
<h4 style="margin: 0 0 10px 0; font-size: 14px;">' || $location_title || '</h4>
<div id="location-filter"></div>
</div>
<div style="min-width: 100px;">
<h4 style="margin: 0 0 10px 0; font-size: 14px;">' || $year_title || '</h4>
<div id="year-filter"></div>
</div>
</div>
<!-- Results container -->
<div id="hits"></div>
<!-- Pagination -->
<div id="pagination" style="margin: 20px 0;"></div>
' as html;
algolia.js:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi I was wondering how to implement Algolia search into SQLPage.
This code below provides a basic implementation of Algolia search in an HTML file. Here's a breakdown of what you need to do:
Replace '
YOUR_APP_ID
' and 'YOUR_SEARCH_API_KEY
' with your actual Algolia App ID and Search API Key.Modify the '
YourIndexName
' in the instantsearch configuration.The search results will display the post title and excerpt.
This implementation uses Algolia's InstantSearch.js library, which provides a quick way to add search functionality to your web app.
To integrate this into your existing app:
Include the necessary Algolia scripts and CSS in your HTML file's section. (This we can do via the
shell
component)Add the HTML elements (#searchbox and #hits) where you want the search interface to appear in your app.
Include the JavaScript code in a <script> tag at the end of your or in a separate JS file.
Beta Was this translation helpful? Give feedback.
All reactions