I’m trying to add the google custom search engine to the header of our discourse forum. I put in the javascript to the head tag and then in the body there is something like <gcse:search linkTarget="_self"></gcse:search> - which will show the google custom search engine.
When I put this in and save it however, it doesn’t show up on the site. I imagine it is being removed by some sort of html filter? (and I should add that by “doesn’t show up” I mean the code itself, not just that the javascript isn’t loading somehow - when I surround it with <!-- -->, the code passes through, but obviously doesn’t work).
This is just a proof of concept, so you’ll have to play around with it to see how/if it can work for your needs. Try adding this to the </head> tab of a theme:
Actually I may have spoke a little too soon… It’s fairly intermittent when it will show up. I had both versions of your script in so I thought this newer one was working (and it did once - minus putting the search bar on top of the menu, etc. - lower half of the header).
The first script appears to work on the front page only if I put in at the body close section - then it shows up at the top of the page oddly.
I’d like to try to get it right below the header bar on top on every page.
Instead of ‘header-contents:after’ - is there a ‘body-contents:before’? that I could try. I went through the api docs, but couldn’t find anything that showed such a declaration…
Sure, if you change it from header-contents:after to just header:after, that should do the trick. You will need to style it with CSS to get it exactly how you want it, but that should get you on track
Purtroppo non posso offrire molto aiuto, dato che non uso più GCSE. L’ho fatto funzionare per un po’, ma alla fine mi sono allontanato da Google in generale e l’ho rimosso molte versioni fa di Discourse. Ciò che è stato pubblicato sopra ha funzionato, ma ho dovuto fare parecchi tentativi per risolvere problemi di scorrimento infinito e per adattarmi ai cambiamenti di Discourse.
Cosa hai provato? E quali errori o problemi hai riscontrato?
Un’opzione più pulita e semplice, che non richieda molta manutenzione, potrebbe essere quella di aggiungere semplicemente un pulsante in alto che reindirizzi a una pagina di ricerca ospitata da Google o a qualcosa di tuo ospitato altrove.
Ho implementato il codice. Ho apportato alcune modifiche CSS per creare una casella di ricerca. Tuttavia, quando faccio clic sull’opzione di ricerca, mi reindirizza per impostazione predefinita alla ricerca di Discourse e non a quella di Google. Qui è dove mi sono bloccato.
Se l’hai configurato ma sta reindirizzando allo strumento di ricerca sbagliato, è probabile che il parametro di query debba essere modificato in modo che entrambi non siano “q=”.
queryParameterName String Il nome del parametro di query—ad esempio, q (predefinito) o query. Questo verrà incorporato nell’URL (ad esempio, Example Domain).
Quindi, il tuo GCSE dovrà essere configurato per utilizzare un nome di parametro di query diverso, come “qr=”; così, quando invii una ricerca, solo il GCSE risponderà, poiché Discourse si aspetta “q=”.
sto utilizzando il tema Overlay per GCSE e vorrei visualizzare i risultati della ricerca nella stessa pagina, non in una pagina diversa, poiché non posso utilizzare il formato a due pagine con Discourse. Tuttavia, il pulsante di ricerca continua ad aggiungere la stringa di query “?search=search+term”.
Questo non genera alcun risultato di ricerca e viene visualizzato il messaggio “Nessun argomento recente”.
Il sito web su cui sto lavorando è: mpl.co
Possiamo collegarci su Google Meet o qualcosa di simile per condividere lo schermo. Fammi sapere, il tuo orario comodo.
Purtroppo non posso, sono un operatore sanitario con un programma molto impegnativo; ho solo pochi minuti tra un paziente e l’altro per dedicarmi a cose del genere.