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
Desafortunadamente, no puedo ofrecer mucha ayuda ya que ya no uso GCSE. Llegué a tenerlo funcionando durante un tiempo, pero terminé alejándome de Google en general y lo eliminé hace varias versiones de Discourse. Lo que se publicó arriba funcionaba, pero tuve que hacer muchos ajustes entre problemas de desplazamiento infinito y cambios en Discourse.
¿Qué has probado? ¿Y qué errores o problemas has encontrado?
Una opción más limpia y sencilla que no debería requerir mucha gestión podría ser simplemente incluir un botón en la parte superior que lleve a una página de búsqueda alojada en Google o a una página propia en algún lugar.
He implementado el código. Realicé algunos cambios en CSS para crear un cuadro de búsqueda. Sin embargo, cuando hago clic en la opción de búsqueda, me redirige por defecto a la búsqueda de Discourse y no a la búsqueda de Google. Aquí es donde me he quedado atascado.
Si lo has configurado pero está yendo a la utilidad de búsqueda incorrecta, es probable que el parámetro de consulta necesite cambiarse para que ambos no sean q=
queryParameterName Cadena El nombre del parámetro de consulta, por ejemplo, q (predeterminado) o query. Esto se incrustará en la URL (por ejemplo, Example Domain).
Por lo tanto, tu gcse tendría que configurarse para usar un queryParameterName diferente, como qr=; así, al enviar la búsqueda, solo gcse responderá, ya que Discourse espera q=
Estoy utilizando el tema Overlay para GCSE. Quiero mostrar los resultados de la búsqueda en la misma página y no en una página diferente, ya que no puedo usar el formato de dos páginas con Discourse. Sin embargo, el botón de búsqueda sigue agregando la cadena de consulta “?search=search+term”.
Esto no está generando ningún resultado de búsqueda y muestra el mensaje “No Latest Topics”.
El sitio web en el que estoy trabajando es: mpl.co
¿Podemos conectarnos en una Google Meet o algo similar para compartir la pantalla? Por favor, házmelo saber, ¿cuándo te viene bien?
Desafortunadamente no puedo, soy un profesional de la salud con una agenda ocupada; solo tengo unos pocos minutos entre pacientes para dedicarme a cosas como esta.