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
Infelizmente, não posso oferecer muita ajuda, pois não uso mais o GCSE. Cheguei a tê-lo funcionando por um tempo, mas acabei me afastando do Google em geral e o removi há várias versões do Discourse. O que foi postado acima funcionava, mas precisei ajustar bastante a solução, lidando com problemas de rolagem infinita e com mudanças no Discourse.
O que você já tentou? Quais foram os erros ou problemas?
Uma opção mais limpa e fácil, que não exigiria muita manutenção, seria simplesmente incluir um botão no topo que leve a uma página de pesquisa hospedada no Google ou a algo seu em outro lugar.
Implementei o código. Fiz algumas alterações no CSS para criar uma caixa de pesquisa. No entanto, ao clicar na opção de pesquisa, ele me leva por padrão para a pesquisa do Discourse, e não para a pesquisa do Google. É aí que estou travado.
Se você já configurou, mas ele está indo para a ferramenta de pesquisa errada, é provável que o parâmetro de consulta precise ser alterado para que ambos não usem q=.
queryParameterName String O nome do parâmetro de consulta — por exemplo, q (padrão) ou query. Isso será incorporado na URL (por exemplo, Example Domain).
Portanto, seu GCSE precisaria ser configurado para usar um nome de parâmetro de consulta diferente, como qr=. Assim, ao enviar a pesquisa, apenas o GCSE responderá, já que o Discourse espera q=.
Estou usando o tema Overlay para o GCSE e gostaria de exibir os resultados da pesquisa na mesma página, e não em uma página diferente, pois não posso usar o formato de duas páginas no Discourse. No entanto, o botão de pesquisa ainda está adicionando a string de consulta “?search=search+term”.
Isso não está resultando em nenhum resultado de pesquisa, aparecendo a mensagem “Nenhum tópico recente”.
O site em que estou trabalhando é: mpl.co
Podemos nos conectar no Google Meet ou algo similar para compartilhar a tela? Por favor, me informe um horário que seja conveniente para você.
Infelizmente não posso, sou um profissional de saúde com uma agenda cheia. Só tenho alguns minutos de cada vez, entre os pacientes, para trabalhar em coisas como essa.